Trying to get the part to spin all the time till a player touched the part than remove the script. I am very new to this. This is what I have and it does not work.
01 | local player = game.Players.LocalPlayer |
02 | local part = script.Parent |
03 | if part.Name = = "Main" then |
04 | script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(. 01 , 0 , 0 ) |
05 | wait() |
06 | else |
07 | if player:Touched(part) then |
08 | script:Destroy() |
09 | end |
10 | end |
11 | player.Character.Humanoid.Touched:connect (part) |
This is because :connect is deprecated, use :Connect.
You tried to pass an object to the :Connect method, which it must be a function.
Also make sure its a Local script to use LocalPlayer
.
01 | local plr = game:GetService( 'Players' ).LocalPlayer |
02 |
03 | function onTouch(part, humanoidPart) |
04 | if part.Name = = 'Main' then |
05 | part.CFrame = part.CFrame * CFrame.fromEulerAnglesXYZ(. 01 , 0 , 0 ) |
06 | elseif part.Parent = = plr.Character then -- if the part parent is of the character |
07 | script:Destroy() |
08 | end |
09 | end |
10 |
11 | plr.Character.Humanoid.Touched:Connect(onTouch) |