What I am trying to do is to get the player to move to a position when it touches a part. This is the script I used
workspace.Custom.Touched:connect(function(hit) local pos = game.Workspace.Spot.Position game.Players.LocalPlayer:MoveTo(pos)
end)
It says MoveTo isn't a valid member of Player, what do I replace it with?
What you need to do is get the character of the player:
workspace.Custom.Touched:connect(function(hit) local pos = game.Workspace.Spot.Position game.Players.LocalPlayer.Character:MoveTo(pos) end)
LocalPlayer can't be accessed in a normal script, but you can use the GetPlayerFromCharacter method to obtain who hit the brick. Start good practices now, like DRY (Don't repeat anything) and index variables before you need them.
local custom = workspace:WaitForChild("Custom") -- You only need to index Spot's position once, unless it moves. local pos = workspace:WaitForChild("Spot").Position -- connect is deprecated, use Connect. custom.Touched:Connect(function(hit) -- Check to see if hit.Parent is a valid member of players local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player and player.Character then local hum = player.Character:findFirstChild("Humanoid") -- Make sure we aren't dead if hum and hum.Health > 0 then player.Character:MoveTo(pos) end end end)