``` 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?
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)