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

How To Make A Tool Unable To Collide With A Part?

I'm making a teleporter for a safezone in my game. When you hold an item though and try going INTO the teleporter, it puts an error in the output saying "moveTo is not a valid member of Tool "Workspace.EmmaMallen.Teleporter", and I tried everything fixing it though it doesn't work.

here's the script.

local TeleportTarget = "Teleporter2"
function Touch(hit)
	if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(TeleportTarget).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(TeleportTarget).Locked = true
		local Pos = script.Parent.Parent:findFirstChild(TeleportTarget)
		hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(TeleportTarget).Locked = false end end
script.Parent.Touched:connect(Touch) 

1 answer

✓ Accepted answer

I'm not sure, but if you go to the roblox API, the page is called Model:MoveTo() https://developer.roblox.com/en-us/api-reference/function/Model/MoveTo

This meaning its only meant to be used on models.

So heres the issue: you're not checking if what touched it is part of a humanoid model.

This code ReWritten:

--Variables
local TeleportTarget = game.Workspace.Teleporter2
--I assume you meant to create a variable for the part you'd like to teleport the player to not create a string.

--Touch is simpler used as an anonymous function, but can also be used that way for organization purposes.
--I assume this scripts parent is the teleporter
Script.Parent.Touched:Connect(function(Touch)
	if Touch:FindFirstAncestorOfClass("Humanoid") then
		local Player = game.Players:GetPlayerFromCharacter(Touch.Parent)
		Player.Character:moveTo(TeleportTarget.Position)
	end
end)

This is the best I can do, as your code is not indented properly and you're using the same lines for different variables. Please clean up your scripts in the future.

11 comments

0

Connection is not a valid member of RBXScriptSignal, what does it mean?

0

Uh oh, i made a spelling error! I meant Connect, fix that spelling mistake or copy the edited script.

0

Pssst.. If this helped mark it as the answer pls i wanna watch numbers on a screen go up

0

Sure.

0

Oh also, I found out that the S in script at line 7 is spelled with a capital. Is that good?

0

its meant to be lowercase im pretty sure.

0

Oh, it still doesn't teleport me, what's the bad thing?

0

What errors?

0

You could try replacing Player.Character:moveTo(TeleportTarget.Position) with Player.Character.HumanoidRootPart(TeleportTarget.Position)

0

Could work!

0

Still doesn't work for some reason, there aren't any output messages and I am officially confused. (the type is R6 and i replaced HumanoidRootPart with torso.)

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