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

How to teleport player after Tool 'Hit'?

So I am not sure where to go with this one, I have a script inside a 'scanner' which once the scanner is activated for a specific tool, when the tool 'hit'' the scanner brick, it will TP the player holding such tool to the other side of a gate (to a brick on the other side).

This is what I currently have although it stalls at the point of teleport so not sure where to go from here.

Line 35 is my teleport.

--Variables--

FCCard = "First"
BCCard = "Business"
PECard = "Priority Class"
ECCard = "Economy"

Brick = script.Parent 
Teleport = script.Parent.Parent.Teleport 
 

opening = false
function OpenGate()
		if opening == false then
		opening = true
		script.Parent.Parent:WaitForChild("Scan").BrickColor = BrickColor.new("Lime green")
		wait(.1)
		script.Parent.Parent.Scan.BrickColor = BrickColor.new("Really red")
		script.Parent.Parent:WaitForChild("LightPart"):WaitForChild("Green").Transparency = 0
		script.Parent.Parent:WaitForChild("LightPart"):WaitForChild("Red").Transparency = 1
		script.Parent.Parent:WaitForChild("Sound"):Play()
		wait(1)
		opening = false
		script.Parent.Parent.LightPart:WaitForChild("Green").Transparency = 1
		script.Parent.Parent.LightPart:WaitForChild("Red").Transparency = 0
		
		else
			return
			end
end


script.Parent.Touched:connect(function(hit)
	if hit.Parent.Name == FCCard and script.Parent.Parent.Parent.Events.FCOpen.Value == true then
		hit.Parent.Parent.Parent.Humanoid.HumanoidRootPart:MoveTo(Teleport.Position)
		OpenGate()
	elseif hit.Parent.Name == BCCard and script.Parent.Parent.Parent.Events.BCOpen.Value == true then
		OpenGate()
	elseif  hit.Parent.Name == PECard  and script.Parent.Parent.Parent.Events.PEOpen.Value == true then
		OpenGate()
	elseif hit.Parent.Name == ECCard and script.Parent.Parent.Parent.Events.ECOpen.Value == true  then
		OpenGate()
end
end)

1 answer

This function causes the Humanoid to attempt to walk to the given location by setting the Humanoid.WalkToPoint and Humanoid.WalkToPart properties.

hit.Parent.Parent.Parent.Humanoid.HumanoidRootPart:MoveTo(Teleport.Position)

If the part parameter is not specified, then the position the Humanoid is walking to will not change. Look over this article it explains it pretty well --Roblox developer - MoveTo

Are you setting the MoveTo to a Brick?

AnotherBrick = game.Workspace.AnotherBrick

script.Parent.Touched:connect(function(hit)
	hit.Parent.Parent.Parent.Humanoid.HumanoidRootPart:MoveTo(AnotherBrick.Position)
end)

3 comments

0

Are you setting the MoveTo to a Part*

0

Hi, Yes I am asking the script to teleport the plr to a part/brick once they hit their tool against a 'scanner'

0

okay idk then sorry, but it also looks like you are setting your Cards to a word with the " ". I would set that to a tool

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