Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why is this script broken? Its supposed to do something when I touch any block with the same name

Asked by
zValerian 108
5 years ago

This is script is supposed to make a THIRSTGUI go up when I touch ANY brick with the name water. However, it doesn't work. It has no errors in console. This is a LOCAL SCRIPT.

local block = "Water"
wait(1)
local debounce = false
local thirst = game.Players.LocalPlayer:WaitForChild("ThirstVal")
repeat wait() until  game.Players.LocalPlayer.Character
local character = game.Players.LocalPlayer.Character

game.Players.LocalPlayer.Character.HumanoidRootPart.Touched:connect(function(p)
    if p.Name == block then
        thirst.Value = thirst.Value + 10
        if thirst.Value > 100 then
            thirst.Value = 100
        end
   end
end)
0
connect is deprecated, use Connect User#19524 175 — 5y
0
still doesn't work zValerian 108 — 5y
0
If this is located somewhere within Workspace then that might be your issue. Try moving it into StarterPlayer > StarterPlayerScripts. Crazycat4360 115 — 5y
0
You could also try print debugging Crazycat4360 115 — 5y
0
1 broken line of code = all the local script's code source will not work properly. cherrythetree 130 — 5y

Answer this question