So i know very little about lua ive basically been taking free scripts and modifying/combining them to do what i need.
so, what i need today is i have this teleport button script
torso = script.Parent.Parent.Parent.Parent.Parent.Character.Torso function onClicked(GUI) torso.CFrame = CFrame.new(Vector3.new(-432, 2.2, 64)) --Put the position of the part here end script.Parent.MouseButton1Click:connect(onClicked)
script.Parent.MouseButton1Click:connect(onClicked) this is for an RPG so i have levels....and i want to make this work but only if you are level for example
i thought i could copy this line into it and have it work but i guess not
player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Lvl.Value >= 1 then
so what i would have after this was
torso = script.Parent.Parent.Parent.Parent.Parent.Character.Torso function onClicked(GUI) player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Lvl.Value >= 1 then torso.CFrame = CFrame.new(Vector3.new(228.6, 393.05, 117)) --Put the position of the part here end
any help on walking me through this would be appreciated :)
local reqLevel = 1 -- the level the player has to be = or > than to click the button local player = game.Players.LocalPlayer -- make this script a local script local pos = CFrame.new(228.6, 393.05, 117) -- or you can do teleportPart.CFrame instead of a raw CFrame script.Parent.MouseButton1Down:connect(function() if player.leaderstats.Lvl.Value >= reqLevel then player.Character:MoveTo(pos + Vector3.new(0,3,0)) end end)
This should work. If it's not, let me know. Make sure you fill in the variables properly.