Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why do these scripts work in Studio but not in game?

The following scripts work perfectly when I test them out in solo in ROBLOX studio, but whenever I actually go in game they don't work. One is supposed to change the player's shirt and pants, and the other is supposed to give the player a GUI to choose a class from.

game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function(char)
        if p.TeamColor.Name == "Bright green" then -- If you just want Bright red players having it
            p:WaitForChild("PlayerGui")
            game.ServerStorage["Class GUI2"]:clone().Parent = p.PlayerGui
        end
    end)
end)

game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function(char)
        if p.TeamColor.Name == "Bright red" then -- If you just want Bright red players having it
            p:WaitForChild("PlayerGui")
            game.ServerStorage["Class GUI"]:clone().Parent = p.PlayerGui
        end
    end)
end)

3 comments

0

Is FilteringEnabled on [as it should be]?

0

Yeah.

0

Can you help?

1 answer

✓ Accepted answer

If your issue is with the bringing of the gui to the character's playergui, then do this should help.

in a Script within ServerScriptService you will need to add the following code:

local screengui = game.ServerStorage["Class GUI"] --[[ The location of the gui you wish to clone ]]
local screenguib = game.ServerStorage["Class GUI2"]

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		if player.TeamColor == game.Teams["Bright red Team"].TeamColor then --[[ This is more reliable, change the 'Bright red Team' to your team's name. ]]
			if player.PlayerGui then
				screengui:clone().Parent = player.PlayerGui
			end
		elseif player.TeamColor == game.Teams["Bright green Team"].TeamColor then
			if player.PlayerGui then
				screenguib:clone().Parent = player.PlayerGui
			end
		end
	end)
end)

If your issue instead, is with the selection of a class within the gui then I will need to see its code.

This has been tested and works, this place will be up for a limited time:

https://www.roblox.com/games/407547884/Scripting-Helpers-answer

If you need further help, pm me on roblox:

https://www.roblox.com/messages/compose?recipientId=18982229

~ Taryo

1 comment

0

Thanks dude, this worked! The GUI is showing, but now I have an issue with class selection. Posted a new question.

This discussion is preserved as it was. New answers, comments, and votes are closed.