local shopPart = game.Workspace.UpgradePlatform


local function onTouch(partTouched)
	local character = partTouched.Parent
	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
	local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)

	function MoveCamera(cframe)

	local cam = game.Workspace.CurrentCamera
    cam.CameraType = Enum.CameraType.Scriptable --Disables player moving camera

    cam.CFrame = cframe --Set camera position

	end
	MoveCamera(CFrame.new((game.Workspace.HackingToolsShopFrame.Item1.lvl1.Position)+Vector3.new(0,0,7)))
	
	game.Workspace.Teleport.RemoteFunction:InvokeServer(player)
	player.Character.Humanoid.WalkSpeed = 0
	script.Parent.Vector.Value = Vector3.new(33.015, -46.097, 105.438)
	end
	
end
shopPart.Touched:Connect(onTouch)

So, when i touch the part, the camera is changed for every player and not only the camera, they're all being teleported. I think the function triggers for every player but why?

6 comments

0

is this a local script

0

yes

0

Check if player == localplayer

0

@Kiriot22 , yep working fine now, i added the condition before line 18

0

Can you mark this as solved in the Question Title? Thanks!

0

Done.