local function onTouch(otherPart) otherPart.Anchored = true local Humanoid = otherPart.Parent:FindFirstChild("Humanoid") if Humanoid then otherPart.Anchored = false print("WORK. JUST WORK") end end
I put this script inside a part, that whatever touches it shall become anchored. If otherPart is a player, then it should print. "WORK. JUST WORK." But it's not working. I'd love some help on this, thanks guys!
Add the following code at the bottom.
script.Parent.Touched:Connect(onTouch(hit))
You can replace 'hit' with 'otherPart' or anything else, it's really up to you.
I think it could be a ROBLOX STUDIO problem. Cause i was doing this yesterday and it was working fine, but now i did it today it didn't work at all. I was trying this script a few minutes ago and it wasn't working.
``
function win()
game.StarterGui.FinishedGame.TextLabel.Visible = true
end
script.Parent.Touched:Connect(win)
``
You need to add the Touched event for the function to fire
local function onTouch(otherPart) otherPart.Anchored = true local Humanoid = otherPart.Parent:FindFirstChild("Humanoid") if Humanoid then otherPart.Anchored = false print("WORK. JUST WORK") end end script.Parent.Touched:Connect(onTouch)
remove local because local used for variables not functions