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

My winners teleporter script doesn't work?!

Hi Please I need someone fix my winners teleport script doesn't work, I want to teleport only players finished all 100 Stages to winners room when player touch the teleporter. this is my script:

function onTouched(hit)  
  print("Teleport")
  local human = hit.Parent:findFirstChild("Torso")
  brick = script.Parent
  if Player.leaderstats.Stages.Value == 100 then
  if (human ~=nil) then
    human.CFrame= CFrame.new(Vector3.new(Position))
   end
end

script.Parent.Touched:connect(onTouched)

1 comment

0

Well first: what's being logged in the output tab? Additionally, are you using R6 or R15?

3 answers

✓ Accepted answer

Use the HumanoidRootPart:

function onTouched(hit)  
  print("Teleport")
  local human = hit.Parent:FindFirstChild("HumanoidRootPart")
  local brick = script.Parent
  if game.Players.LocalPlayer.leaderstats.Stages.Value == 100 then
  if (human ~= nil) then
    human.CFrame= CFrame.new(Vector3.new(Position))
   end
end

script.Parent.Touched:Connect(onTouched)

There were also 2 other mistakes I noticed:

  • Capitalize "findFirstChild". The original version is completely deprecated.

  • Capitalize "connect". The original version is not completely deprecated, but capitalize it to avoid bugs.

1 comment

1

You are awesome thanks a lot <3

Thank you all guys, I really appreciate your cooperation with me. I tried the script by MCAndRobloxUnited At first it did not work but when I added "end" in line 10 it works with me, but when I published the game it doesn't work, It is only work in ROBLOX Studio. Please help me guys. this is the script I used by MCAndRobloxUnited:

function onTouched(hit) 
  print("Teleport")
  local human = hit.Parent:FindFirstChild("HumanoidRootPart")
  local brick = script.Parent
  if game.Players.LocalPlayer.leaderstats.Stages.Value == 100 then
  if (human ~= nil) then
   human.CFrame= CFrame.new(Vector3.new(Position))
   end
end
end

script.Parent.Touched:Connect(onTouched)

1 comment

0

Well, what are you using in game; R6 or R15? This is looking for the 'HumanoidRootPart' something of which is only found in R15 character models as a replacement for Torso, if you are using R6 in game then this is why it isn't working.

Your teleport line (7) does not work. You can't fuse CFrame and position.

The script is very confusing for me, so I'll just make a easier to read version of your script that still works.

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Torso") ~= nil and then
		local character = hit.Parent
		local torso = character.Torso
		local player = game.Players:GetPlayerFromCharacter(character)

		if player.leaderstats.Stages.Value == 100 then
		--Read what I said bellow in my reply.
		end
	end
end)

[Line 5] This line takes the character and finds its player.

[Line 8] I recommend you make a variable of another part where you want your character to teleport. Example:

local otherpart = workspace.OtherPart
local torso= workspace.Character.Torso

torso.CFrame = otherpart.CFrame

Sorry if I misunderstood your question, but I tried to answer it with my best.

1 comment

0

You are awesome thanks a lot <3

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