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)
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 .
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)
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().
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.
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.