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

Help With A Sorta VIP Script?

I made a script that teleports you into a certain room, but it was made to only teleport me. However, this script won't work. I made this so far.

function onTouch(part)
	local playyer = part.Parent
	if playyer.Name = ("Player") then
		local torso = part.Parent:FindFirstChild("Torso")
		if torso ~= nil then
			torso.CFrame = CFrame.new(56,26,-94)
		end
	end
end

script.Parent.Touched:connect(onTouch)

It says that it expected a 'then' near the '=' But I have no idea what it means. The script seems fine, I just don't get it.

2 comments

0

Line 03 needs a double equal sign for equal to.

1

Your problem is at line 3; You need to use '==' to compare a Condition to an Argument, '==' is when your comparing, '=' is when your Setting a Variable to a String, Number, Object, ect. :P

2 answers

✓ Accepted answer
function onTouch(part)
    local playyer = part.Parent
    if playyer.Name == ("Player") then -- When Comparing values, use 2 equal signs, not one.
        local torso = part.Parent:FindFirstChild("Torso")
        if torso ~= nil then
            torso.CFrame = CFrame.new(56,26,-94)
        end
    end
end

script.Parent.Touched:connect(onTouch)


1 comment

0

Thanks so much! I can't believe I forgot that 0-0

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