it was working before, and now its not working even though i didnt change anything
game.ReplicatedStorage.Server.CamShake.OnClientEvent:Connect(function(timeDel, power, dur)
if power == nil then power = 1.5 end
if dur == nil then dur = 5 end
local char = game.Players.LocalPlayer.Character
for i=1,dur do
local x = math.random(-100,100)/100 * power
local y = math.random(-100,100)/100 * power
char.Humanoid.CameraOffset = char.Humanoid.CameraOffset:lerp(Vector3.new(x,y,0),timeDel)
wait()
end
char.Humanoid.CameraOffset = char.Humanoid.CameraOffset:lerp(Vector3.new(0,0,0),.1)
end)
Okay with a bit of thinkering I think I got your solution
local plr = game.Players.LocalPlayer
game.ReplicatedStorage.Server.CamShake.OnClientEvent:Connect(function(timeDel, power, dur)
if power == nil then power = 1.5 end
if dur == nil then dur = 5 end
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
for i=1,dur do
local x = math.random(-100,100)/100 * power
local y = math.random(-100,100)/100 * power
hum.CameraOffset = hum.CameraOffset:lerp(Vector3.new(x,y,0),timeDel)
wait()
end
repeat
hum.CameraOffset = hum.CameraOffset:lerp(Vector3.new(0,0,0),.1)
wait()
until hum.CameraOffset == Vector3.new()
end)
You’re not lerping at the end till the offset is 0 for each axis, so it lerps once and that’s it. It’s also good to wait for the character and the Humanoid to exist before trying to lerp in the event that they don’t exist, or if needed, just do some checks and if either the character doesn’t exist or the humanoid doesn’t exist, just don’t run anything
Also you may need to thinker with default values as the default duration is almost instant and perhaps the power a bit. If this doesn’t work either, it’s probably an issue with how you’re firing the event
Edit: Since I never asked, what was the original issue you were facing?
There was no issue few weeks ago, i didnt even change anything i dont even know what is happening.
I even tried printing to see if the firing problem is not working
Edit: and the code you sent me is not working too
It’s probably an issue as to how you’re firing the event, from where are you firing it? Did you make any changes to anything fro mweeks ago till now?
ModuleScript and Server Script.
i didnt make any changes few weeks ago till now
Did you change anything involving firing the event? How are you firing it anyways?
game.ReplicatedStorage.Server.CamShake:FireClient(p, 0.1, 5, 20)
Does the code around it work? Any errors? What does the entire script look like?
No errors
for count = 1, 5 do
for i,v in pairs(game.Players:GetPlayers()) do
if v.Character and v.Character:FindFirstChild("HumanoidRootPart") then
game.ReplicatedStorage.Server.CamShake:FireClient(v, 0.1, 10, 20)
end
end
wait(0.1)
end
Is this happening as soon as the server starts or is there a delay as to when this code runs?
Also you can use FireAllClients
instead of looping through all the players and just do some checking in the Event to see if the character exists and what not
there is delay for the code to run
and this is not working too
for count = 1, 5 do
game.ReplicatedStorage.Server.CamShake:FireAllClients(0.1, 10, 20)
wait(0.1)
end
i did try printing at the localscript and it say it is fired
Is that the only code in the server script or is there anything else?
function module.camShake()
spawn(function()
for count = 1, 5 do
game.ReplicatedStorage.Server.CamShake:FireAllClients(0.1, 10, 20)
wait(0.1)
end
end)
end
just these for the function
Oh this is a module, and where does it get used?
it is used in normal server script
And what’s the code of that server script?
local camMod = require(game.ServerScriptService.CamModule)
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
camMod.camShake()
end
end
I think it could be cause you don’t have a debounce? Try this as a test
local camMod = require(game.ServerScriptService.CamModule)
local deb = false
script.Parent.Touched:Connect(function(hit)
if deb then return end
if hit.Parent:FindFirstChild("HumanoidRootPart") then
deb = true
camMod.camShake()
wait(5)
deb = false
end
end
nope still not working
im starting to think its about roblox problem
It could be, what happens if you just put the code in that function in the event instead of running the camShake
function?