I'm currently making a half life mod in Roblox and I'm trying to make it so that if you press a button in the main menu it teleports you to a select map. I already wrote a script for this but for some reason the code just wont execute and I don't get anything in output. The script is a local script and is a child of StarterGUI. Here is the code:
--\Buttons/ local btn1 = game.StarterGui.menu.main.gm_prompt.lbl_troom -- training room button local main = game.StarterGui.menu.main local maps = game.ReplicatedStorage.maps local cmap = workspace.current_map local char = game.Players.LocalPlayer.Character local hroot = char:WaitForChild("HumanoidRootPart") -- --Map Loader-- btn1.MouseButton1Click:Connect(function()-- executed on click of troom button print("swear if it didn't work") cmap.spwn_box:Destroy() -- Destroys spawn box maps.c0p1.Parent = workspace.current_map main.Visible = false hroot.CFrame = maps.c0a1:WaitForChild("tp").CFrame end)
Thanks in advance and sorry if its spaghetti I'm new and bad at coding
Try putting the local script under the button and setting btn1 to script.Parent.
You said it is in StarterGUI, right? Instead of doing.
local btn1 = game.StarterGui.menu.main.gm_prompt.lbl_troom
Try to do this instead.
local player = game.Players.LocalPlayer local btn1 = player.PlayerGUI.menu.main.gm_prompt.lbl_troom
The reason why it may not work is because everything is copied from StarterGUI to the PlayerGUI so you need to access the PlayerGUI for it to work. If it still doesn't work, please comment back.