Reputation: 91
I tried to make a code that's shake the camera player when a RemoteEvent is fired by a key on the keyboard. But it didn't worked. I tried to use the CameraOffset but didn't worked too. How can i make this code without using the CameraShakeModule??? Any sugestion??? Code below:
local ts = game:GetService("TweenService")
local replicated = game.ReplicatedStorage
local powers = replicated.Powers
local Info = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local ss = game:GetService("ServerStorage")
local FireWind = ss.FireWind:Clone()
powers.GiantFire.OnServerEvent:Connect(function(Player, Hit)
local char = Player.Character or Player.CharacterAdded:Wait()
local SuperFireSphere = Instance.new("Part")
local hrpp = char.PrimaryPart
local currentcam = workspace.Camera
currentcam.CameraSubject = char.Humanoid
currentcam.CameraType = Enum.CameraType.Scriptable
SuperFireSphere.Shape = Enum.PartType.Ball
SuperFireSphere.Material = Enum.Material.Neon
SuperFireSphere.BrickColor = BrickColor.new("New Yeller")
SuperFireSphere.Anchored = true
SuperFireSphere.CanCollide = false
task.wait(.2)
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Velocity = CFrame.lookAt(hrpp.CFrame.Position, Hit.Position).LookVector * 150
hrpp.Position += Vector3.new(0, 50 , 0)
hrpp.Anchored = true
SuperFireSphere.Parent = workspace
FireWind:SetPrimaryPartCFrame(hrpp.CFrame)
FireWind.Parent = workspace
SuperFireSphere.Position = char.PrimaryPart.Position + Vector3.new(0,15,0)
for i = 1, 15 do
task.wait(.1)
SuperFireSphere.Size += Vector3.new(2,2,2)
end
for i, parts in pairs(FireWind:GetDescendants()) do
if parts:IsA("MeshPart") then
local tween = ts:Create(parts, Info, {Transparency = 1})
tween:Play()
end
end
for i = 1,20 do
local x = math.random(-100, 100)/100
local y = math.random(-100, 100)/100
local z = math.random(-100, 100)/100
char.Humanoid.CameraOffset = Vector3.new(x,y,z)
print(i)
task.wait(.5)
end
local FireParticle = ss.Fire:Clone()
FireParticle.Parent = SuperFireSphere
SuperFireSphere.Anchored = false
bv.Parent = SuperFireSphere
task.wait(2)
hrpp.Anchored = false
FireWind.Parent = ss
for i, parts in pairs(FireWind:GetDescendants()) do
if parts:IsA("MeshPart") then
parts.Transparency = 0
end
end
task.wait(5)
SuperFireSphere:Destroy()
end)
Upvotes: 1
Views: 466
Reputation: 118
Your problem is that you made the CameraType
scriptable, with it scriptable, the character's Humanoid
no longer has control of it. Remove the lines that make the CameraType
scriptable and it will solve your issue.
Upvotes: 0