Hi. I am trying to do a Thirst and Hunger script.
This is inside my script:
game.Players.PlayerAdded:connect(function(player)
while wait() do
wait(20)
script.SendSignal:FireClient(player)
end
end
I have tried without player added, and without the player argument, and it didn't work. Then I tried with the player added, and nothing happened. I don't know how to define the player.
LocalScript:
local SSS = game:GetService('ServerScriptService')
local SendSignal = SSS.HungerScript.SendSignal
local player = game:GetService('Players').LocalPlayer
SendSignal.OnClientEvent:connect(function()
if script.Parent.Hunger.Value >= 0 then
script.Parent.Hunger.Value = script.Parent.Hunger.Value -1
end
if script.Parent.Hunger.Value <= 0 then
repeat
wait(5)
player.Character.Humanoid.Health = player.Character.Humanoid.Health -2
until script.Parent.Hunger > 0
end
end)

1 comment
The first script will work fine, are you sure you waited 20+ seconds before confirming it didn't work? As for the second script why not put the event in replicatedstorage? ServerScriptService will not replicate to clients