so ive got an RPG and part of my GUI is a teleport book, you press a button it opens the book and you get a list of teleports with buttons next to them.....when you click a button it sends you there.....
my script works fine when test running in studio but does nothing online, any ideas why it would do this?
here is the script the button runs
local reqLevel >= 1 local player = game.Players.LocalPlayer local pos = CFrame.new() script.Parent.MouseButton1Down:connect(function() if player.leaderstats.Lvl.Value >= reqLevel then player.Character:MoveTo(Vector3.new(408.486, 378.5, -415.248)) end end)
i did not write this script fully, i took a telelport script and added the level req, so plz if something is written wrong point it out so i can fix it :P
Well, Roblox works very different than we imagined. I believe you need to use WaitForChild()
WaitForChild()
Is just another way for having the variable wait for it to fully load. So you should in my suggestion use WaitForChild()
in either local Player
or make a variable for the Teleport button. So this it what it would look like.
local reqLevel >= 1 local player = game.Players:WaitForChild("LocalPlayer") local pos = CFrame.new() local Tele = game.StarterGui--Parent here of Teleport Button--WaitForChild("TeleportButton") script.Parent.MouseButton1Down:connect(function() if player.leaderstats.Lvl.Value >= reqLevel then player.Character:MoveTo(Vector3.new(408.486, 378.5, -415.248)) end end)
It worked for me before in the past whenever I wanted a textButton or something like that to work. Hope this helps. Or if it doesn't, then tell me.
EDITED:
The Variable for Teleport Button or the new definition of local Player
is completely optional!