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

Script for teleporter not working as i want it to?

local currentlevelvalue = game.Players.LocalPlayer.leaderstats.Level.Value
local pad = script.Parent
local teleportTo = workspace.level:FindFirstChild(currentlevelvalue)

pad.Touched:connect(function(hit)
 local humanoid = hit.Parent:FindFirstChild("Humanoid")
 if humanoid then
  local humanoidRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
  if humanoidRoot then
   humanoidRoot.CFrame = teleportTo.CFrame
  end
 end
end)

I want to create a block that on contact teleports you to a certain brick depending on your leaderboard score for example if your Level leaderboard value was 3 you would get sent to the brick called Level3. I'm not sure how to do this. I'm fairly new to lua but this is what i have. Could someone help me fix this code so it can perform the task i want?

1 comment

0

Same Problem with a Player

1 answer

✓ Accepted answer

It appears your script is local. It wont work. You need to change your Localscript to script. However it still won't work. That is because you no longer can use LocalPlayer property. You need to make adjustments.

local pad = script.Parent
local Players = game:GetService("Players")

pad.Touched:connect(function(hit)
 local humanoid = hit.Parent:FindFirstChild("Humanoid")
 if humanoid then
  local humanoidRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
  if humanoidRoot then
   local player = Players:GetPlayerFromCharacter(hit.Parent)
   local currentlevelvalue = player.leaderstats.Level.Value
   local teleportTo = workspace.level:FindFirstChild(currentlevelvalue)
   humanoidRoot.CFrame =  teleportTo.CFrame
  end
 end
end)

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