Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why can't I use RemoteEvent:FireAllClients?

I want to check whether a character is in a Region3 at a certain time on the server, so I made a remote event called FloorCheck. Now, I put this in my main Script when I want to check:

if game.ReplicatedStorage:FindFirstChild("FloorCheck") then
	print("FloorCheck exists")
end
game.ReplicatedStorage.FloorCheck:FireAllClients()

Here is what I put in a LocalScript:

script.Parent.FloorCheck.OnClientEvent:Connect(function()
	print("Recieved FloorCheck RemoteEvent")
	local RegionThree = Region3.new(564.523, 3.261, 23.901,518.588, 8.317, 57.639)
	local Parts = workspace:FindPartsInRegion3(RegionThree)
	if table.find(Parts, game.Players.LocalPlayer.Character.HumanoidRootPart)==nil then
		game.Players.LocalPlayer.Character.Humanoid.Health=0
	end
end)

Now I see FloorCheck exists but no Recieved FloorCheck RemoteEvent in the output. Why? How can I fix this?

1 comment

0

put the local script in starter player scripts (do like game.repstorag.floorcheck.onclientevent). i think you would also want the fireallclients line inside the if statement

1 answer

This is a common mistake.

you cannot put local scripts outside of the local player, or the local player's character. so put the local script in StarterPlayerScripts or StarterCharacterScripts instead. Or else, the local script won't work.

also, a part of the local script is wrong as well. you should've done this:

script.Parent.FloorCheck.OnClientEvent:Connect(function()
	print("Recieved FloorCheck RemoteEvent")
	local RegionThree = Region3.new(Vector3.new(564.523, 3.261, 23.901),Vector3.new(518.588, 8.317, 57.639))
	local Parts = workspace:FindPartsInRegion3(RegionThree)
	if table.find(Parts, game.Players.LocalPlayer.Character.HumanoidRootPart) == nil then
		game.Players.LocalPlayer.Character.Humanoid.Health=0
	end
end)

1 comment

0

I changed line 3 of the local script. You can check what i changed

This discussion is preserved as it was. New answers, comments, and votes are closed.