How would I make a script where after touching a block (lets say 10 times) will turn on?
add a script to your light part (not the pointlight itself), and then type this in the script
script.Parent.Parent.PointLight.Enabled = false local touched = 0 script.Parent.Touched:Connect(function(player) touched = touched + 1 if touched < 10 then else script.Parent.Parent.(LightName).Enabled = true end end)
See if this works! If it doesn't, tell me.
Thanks for the reply! I've figured it out. Originally I had the second conditional statement outside of the function, but once I put it inside it worked.
local timesTouched = 0 script.Parent.PointLight.Enabled = false script.Parent.Touched:Connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) then timesTouched = timesTouched + 1 if timesTouched >= 10 then script.Parent.PointLight.Enabled = true end end end)
If there is anything I can do to make this better please let me know as I am pretty new to scripting!
Simple enough.. I think I got it right.
local part = --your part touchend = 0 function TurnLightOn() --add a script that turns the light on idk end function onPartTouched(otherPart) touchend = touchend + 1 end if touchend >= 9 then TurnLightOn() end part.Touched:Connect(onPartTouched)