I’m trying to make it so a leaderstats value is increased when a union is touched but then there is a cool down on touching that union. When the player touches the union nothing happens. There are no errors in the console regarding anything related to this script. I have read the dev hub page on the function Touched to see if I’m doing something wrong but I couldn’t find anything that could help. I have also tried other ways of detecting touches but it still wouldn’t work.
The script is:
local leaf = script.Parent
local canEat = true
local function onPartTouch(otherPart) if canEat == true then print("touched") canEat = false script.Parent.Transparency = 0.5 local player = game.Players:GetPlayerFromCharacter(otherPart.Parent) player.leaderstats.GiraffeBux.Value = player.leaderstats.GiraffeBux.Value + 1 wait(5) canEat = true script.Parent.Transparency = 0 end end leaf.Touched:Connect(onPartTouch)
Here is the model for reference. tree.rbxm (6.7 KB) (It’s too tall for a normal character because I have a custom character that is taller than average.)