Answered by
5 years ago Edited 5 years ago
The touch event fires whenever any player touches the part, even if it's in a local script.
Though, I see what you are trying to do, to get the part to only move when the local player touches it.
To prevent the part from moving whenever any player touches it, you might want to check if the player that touched the part is the local one. If so, then do the loop.
01 | local players = game:GetService( "Players" ) |
02 | local player = players.LocalPlayer |
04 | Move = game.Workspace.MovingPlatform.Platform |
05 | Move 2 = game.Workspace.MovingPlatform.Touch |
07 | Move 2. Touched:Connect( function (hit) |
09 | local humanoid = hit.Parent:FindFirstChild( "Humanoid" ) |
12 | local character = humanoid.Parent |
13 | local plr = players:GetPlayerFromCharacter(character) |
15 | if (plr = = player) then |
19 | Move.CFrame = Move.CFrame * CFrame.new(Vector 3. new( 0.1 , 0 , 0 )) |
I would also suggest to have a look at the TweenService, it can come on pretty handy sometimes!