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

What is wrong with this script?

It's supposed to give a class selection GUI if a player has a certain team color. Output doesn't say anything either.

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

('Storage' is a folder in ReplicatedStorage.)

4 comments

0

Where is the script located?

0

What kind of script is this and where is it

0

It is a normal script, and located in Workspace.

0

On line 4, if filtering enabled is set to true, scripts can't access PlayerGui. similarly , scripts can't access ReplicatedStorage when filtering enabled is set to true.

1 answer

✓ Accepted answer

On line 4, if filtering enabled is set to true, scripts can't access PlayerGui. similarly , scripts can't access ReplicatedStorage when filtering enabled is set to true. In order to fix these problems, you first need to use Remote Events to connect the server with the client. Here's a video that helped me with Remote Events. There are more videos you can find on youtube if needed. Next is a bit more simple. Basically, Scripts can't access ReplicatedStorage and Local Scripts can't access ServerStorage. This is for security reasons. So in order to make the script access the Class Gui, Move it to ServerStorage.

A simpler way of solving. A better way of doing this is to leave the Class Gui in replicated storage and do everything in the script in a local script that's connected to a RemoteEvent. Now I'm sure this is very confusing to you, mostly because I'm not doing the best job at explaining this, but the videos and links should help. Here's one more link about filtering enabled, and when you should use it. Thank ScriptGuider for this one.

Anyways, Good Luck! I hope I helped.

2 comments

0

Thanks dude! I was finally able to figure it out! It works perfectly.

0

That's awesome.

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