RemoteEvent doesn't fire when player touches a part

I’m making a boat sailing game. I’m trying to make it so that when the tip of the boat touches a part the player’s camera shakes. I have a RemoteEvent placed in ReplicatedStorage named “ShakeEvent”. The problem is that the event only fires when I use a simple wait() timer. If I try to use a .Touched event or a while true do loop, it doesn’t fire. The script that triggers the event is in ServerScriptService and the RemoteEvent is in ReplicatedStorage

Camera does shake (event fires):

local ShakeEvent = game.ReplicatedStorage:WaitForChild(“ShakeEvent”)
wait(5)
ShakeEvent:FireAllClients(5)

Camera does not shake

local trigger = game.Workspace.triggerpart2
local ShakeEvent = game.ReplicatedStorage:WaitForChild(“ShakeEvent”)

trigger.Touched:Connect(function()

ShakeEvent:FireAllClients(5)
print("yes")
    trigger:Destroy()

end)

2 Likes

Question. Why you use FireAllClients if you need to do shake camera of one player? Instead use FireClient with player property
Also try adding print in client code to see if client receives this event
Also can you provide client code

2 Likes

By client code do you mean the script I use to make the camera effect? I’m new to scripting. If so, here it is:

local ShakeEvent = game.ReplicatedStorage:WaitForChild(“ShakeEvent”)
local Character = script.Parent
local Humanoid = Character:WaitForChild(“Humanoid”)

ShakeEvent.OnClientEvent:Connect(function(Time)

print("client worked")

local StartTime = tick()



repeat

	wait()

	local EndTime = tick()

	local xOffset = math.random(-100, 100) / 500
	local yOffset = math.random(-100, 100) / 500
	local zOffset = math.random(-100, 100) / 500

	Humanoid.CameraOffset = Vector3.new(xOffset, yOffset, zOffset)

until EndTime - StartTime >= Time
Humanoid.CameraOffset = Vector3.new(0, 0, 0)

end)

I put in a print(“client worked”) and it does show in the output, but the camera doesn’t shake

1 Like

Well then that’s not RemoteEvent issue then. Let me try your code in baseplate and find issue

1 Like

I can say what this code works fine and properly. I just tryed this in baseplate and everything fine(i copy pasted your code). You sure you put this code in starting character script?

It is in StarterCharacterScripts and its a LocalScript. Is that the problem?

No, everything fine. I used same path. You sure what your camera shake is not overrided by something different

I tried many different methods and I dont know why it only works if I use a simple wait() timer like this

local ShakeEvent = game.ReplicatedStorage:WaitForChild(“ShakeEvent”)
wait(5)
ShakeEvent:FireAllClients(5)

Is that camera part is instantly under player when he joins? Like this:
image

No. its away from the player’s spawn

Then it should work…? Because i tested it like 15 times and it always shake camera

im going to try it in a baseplate and see if I find something

1 Like

Ok so it works in a brand new baseplate, but not in my actual game

As i said check if something override player camera

found it. I was using a vehicleseat for the boat which changes your camera subject

1 Like

Alright. Good luck with your game

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.