Hi there, I have a script for assigning weapons that works perfectly fine in roblox studio, but not in the actual game, or the server test mode. Any help would from coders more experienced than myself would be very appreciated.
When I join the game in any way except for solo test, the GUI does not appear at all.
game.Workspace:WaitForChild(game.Players.LocalPlayer.Name)
player = game.Players.LocalPlayer
backpack = player.Backpack
script.Parent.Main.Visible = true
function chooseClass(class)
for i, v in pairs(backpack:GetChildren()) do v:remove() end
for i, v in pairs(class:GetChildren()) do
if v:IsA("Tool") then
v:clone().Parent = backpack
elseif v:IsA("HopperBin") then
v:clone().Parent = backpack
end
end
script.Parent.Main.Visible = false
script.Parent.Title.Visible = false
end
function onHumanoidDied(humanoid, player)
script.Parent.Main.Visible = true
script.Parent.Title.Visible = true
end
for i, v in pairs(script.Parent.Main:GetChildren()) do
v.MouseButton1Up:connect(function () chooseClass(v) end)
end

9 comments
Thank you for the detailed response, I had no idea I was so out of date! The new script works perfectly in Studio as well, but absolutely refuses to show up in-game.
I edited it, this should work. If it still doesn't, please tell me if there are any errors.
No luck, It still doesnt show up in the game, despite the console not returning any relevant errors.
hm
Could you elaborate on what you want to happen?
I can. In test mode, a GUI appears when a player spawns in for the first time, prompting them to select a class. Once a class is selected, if it functions correctly, it will empty the player's backpack, assign a morph to the player, assign the class's weapons, and hide itself.
The script I posted is under a ScreenGui named "WeaponChooser", next to all of the textlabels with scripts inside of each respective one.
Do you want the gui to show only for the first time they spawn, and never again (until they rejoin)?
Eventually, but for now I would like it to re-appear after the character respawns.