So I have a part in my game with a script in, the script says this:
function onTouch() while true do StarterPlayer.StarterCharacter.UpperTorso.BodyFrontAttachment.Beam = true end end script.Parent.Touched:connect(onTouch)
Im not sure whats wrong with the script, I myself being completely new to scripting have no idea myself so can I get some help here please?
The basic idea is that when the player touches the part (there is already an attachment and beam connected to the part the beam is going to) the script registers the part being touched and goes to the starterplayer where my custom avatar is sitting (it works being a custom avatar too) and it goes into the character and the uppertorso andthen finds the attachment that has the beam in it (I put all this in the script above) at the moment the beam is disabled (enabled button but not checked) and the script needs to enable it when the player steps on it. When the player steps off of the part I also want the beam to be disabled again (however I had a thought on turning the beam on I have no clue of turning it off seeing as what I think for turning it off doesnt work) I have no clue where it is going wrong. Please help me as soon as you can :)
script.Parent.Touched:connect(function(plr) plr.Character.Humanoid.UpperTorso.BodyFrontAttachment.Beam = true end)
That will work.