This topic is closed
Check if player exists,
Your getting the player from the character but the argument your sending might not be valid so its returning nothing
What do you means by that, the script works but it sends error even if it works completly
i tried with waitforchild, it didn’t had errors, but it made everyone lag because of the warn spamming
Add a debounce and see if it stops
The error occurs inside the function, meaning that it can be called again once the Touched event is fired. While the thread stops there, when you touch the part again it can work properly; so it may look like there are no flaws while the output shows otherwise.
The error happens because when something (not someone) touches the Hill part, the script cannot find any player from it. Thus, you are trying to index PlayerGui and apply FindFirstChild to nil.
What @FruitySama means is this:
local player = game.Players:GetPlayerFromCharacter(human) -- lines 9 and 29
if not player then
return
end
Adding that if
statement in both places will make it not error anymore.
Ok thank you i’ll let you know after trying this
Thank you, it worked.
It was my first time using touch event so that’s why i didn’t know.