I don't know why RemoteEvent is not triggering

I don’t know why RemoteEvent is not triggering

not printing “OK”

local Remote = game.ReplicatedStorage.RemoteEvents.Add_Stage
local Debaunce = false

script.Parent.Touched:Connect(function(Hit)
if Debaunce == false then
Debaunce = true

local Number = tonumber(script.Parent.Parent.Name)
local BillBoard = script.Parent.BillboardGui

if Hit.parent:FindFirstChild("Humanoid") then
if Hit.parent:FindFirstChild("Humanoid").Health>0 then

print("ok")
Remote:FireServer(Number, BillBoard)

end
end
end
wait(2)
Debaunce = false
end)
1 Like

You should incorporate tabs or spaces to make your code easily readable. Apart from that, you should check to see if all the conditions are met. Typically, code within an if-statement is not being executed due to the condition being false .

Hope this helps!

1 Like

the Touched system Doesn’t work in Local Script? I tested it now and the problem is that the function is not firing

What is this script supposed to do? Where is it located?

is located in ScriptService but it will be transferred to workspace

this script should check if the player is alive, first, and then it would activate a RemoteEvent sending the “Number” (value q will be set to DataStore2) and then the Normal Script in the service script would set the datastore and would take the billboard and exchange colored text to green

If this is a server script then you don’t use FireServer() because it’s already on the server.

For the server to communicate with a client you would use FireClient() and you would also pass in a player instance as the first argument.

To get the player from a Touched event you can use a line like this:
local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
Check if the player is not nil then fire the event with:
Remote:FireClient(player, Number, BillBoard)

Screenshot_19

Screenshot_20

Screenshot_21

As Blokav stated, you’re trying to fire an event to the server from the server, which doesn’t really make sense in this case since you’re using a remote event, which is used to communicate from server to client, and vice-versa.

If you’re trying to edit something on the client (locally) through that remote event, which is what it looks like you’re trying to do, you should be using FireClient() instead of FireServer().

It should look something similar to this:

Remote:FireClient(player, Number, BillBoard)

The listener on the client would look like:

Remote.OnClientEvent:Connect(function(Number, BillBoard) 

end)

The player would not be a parameter in this function, and instead you can find the player with the following variables:

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

There is some other suggestions I have for your code, but they don’t necessarily pertain to this issue. You should probably start getting used to tabbing your code in as that’s a common practice within most programming languages, and I would personally check to see if what’s touching the part is a character before I define any variables.

Try and see what would happen if you wrote Parent instead of parent for hit

LocalScripts will not run if it is not a descendant of ReplicatedFirst, the player’s backpack, player gui, player scripts, or a descendant of the player’s character. Move the LocalScript to somewhere else and see what happens.