Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make a part where, on touch, makes the player moved to the desired location?

Title explains everything. How would I make a part where, if I touched said part, your player would automatically move (without touching any keys) to the set location? I'm not talking about teleporting a player to a location btw, I'm talking about having the player walking to desired location. Thanks!

1 comment

0

Please make an attempt first.

2 answers

For this example i put the script in the part

script.Parent.Touched:Connect(function(hit) --checks parent(Part) for touching and puts the part that touched it into a variable called hit
	if hit.Parent:FindFirstChildOfClass("Humanoid") then --checks if the part is the part of a players character
		local Position = Vector3.new(5,5,5) --the position that you want to teleport to(5,5,5 is just for example). To get the position you want to teleport to you can move a brick there and copy the Position property or put YourPartName.Position as the Position variable to teleport to a part
		hit.Parent:MoveTo(Position) --Move the character to the position you choosed
	end
end)

Wiki Pages:

MoveTo

Vector3

Touched

FindFirstChildOfClass

I put alot of time and effort into writing these answers and would really appreciate if you accepted my answer as the solution(if it worked. Please comment if it didn't soo i can change it to make it work) and upvoted it

Most of my answers are tested in Roblox Studio and should work

part.Touch:Connect(function(hit)
	local desired_position =  -- *Position of the place or part*--
	character.Humanoid:MoveTo(desired_position)
end)

1 comment

0

-1 for no explanation and incorrect event name.

This discussion is preserved as it was. New answers, comments, and votes are closed.