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?
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)