Player moving even though there's no input given?

Hey All!

I have a script that at first keeps the player in serverstorage an when the player clicks play it puts it in workspace in a set position. The code works, but right when the player gets teleported to workspace he runs straight forward with no input given. Here’s an example.
https://streamable.com/53kkt0

I also tried anchoring the player which works to keep it in place, but I want to use pathfinding on it a bit later and from what I’ve seen that doesn’t work if the HumanoidRootPart is anchored. This is what it looks like anchored.
https://streamable.com/qqoq7u

Here is my script if any of you want to see it.

local playEvent = game.ReplicatedStorage.PlayEvent
local once = false

game.Workspace.ChildAdded:connect(function(character)
	if game.Players:GetPlayerFromCharacter(character) then
		if once == false then
			once = true
			char = character
			wait(.5)
			character.Parent = game.ServerStorage
		end
 	end  
end)

playEvent.OnServerEvent:Connect(function()
	local HumRoot = char:FindFirstChild("HumanoidRootPart")
	HumRoot.Position = Vector3.new(0.002, 6.678, 22.38)
	--HumRoot.Anchored = true
	wait(.5)
	char.Parent = game.Workspace
end)

The only other piece of info I can give is that the spot that the character runs to is the place where it would spawn without this script running. If you need any additional info ask.
Thanks!

I hope you don’t mind me asking, but why are you putting the player in ServerStorage?

You don’t have to put the player in ServerStorage when in a menu screen, they can just be temporarily put inside a spawn box. If you put a character inside the ServerStorage, the client loses control over it because clients can’t access the ServerStorage, only the server can.

2 Likes

Not really sure what you mean but you could just set the player’s parent to nil and i do not see any need to use a remote event when clicking a button if there is nothing to check with the server or if your camera scripts are just in the server.

-- client / localscript
game.Players.LocalPlayer.Character.Parent = nil

script.Parent.Button.MouseButton1Click:Connect(function() -- click the button
      game.Players.LocalPlayer.Character.Parent = workspace -- set the player's char to workspace
      game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = workspace.SpawnPoint.CFrame -- use CFrame or else the player would die when you teleport a important part of it away.

end)

Hope this helped
Ps i am still the real arrowman

I’m not sure that was just the place I thought was best for it.

@THEsuperTERROR
I’m pretty sure your idea will work, but I’m going to try it now.
Edit: It worked

@Suuzv
Setting it to nil doesn’t change anything, and I have reasons for needing the remote event, I just haven’t used it yet.
P.S if your name’s not arrowman you’re not the real arrowman

ServerStorage is a container that is only accessible from the server. As @THEsuperTERROR mentioned, clients have no access to it. You shouldn’t put anything in there that the client requires access to. Unless, of course, it’s for security reasons. In that case you would use RemoteEvents/RemoteFunctions.