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

My GUI in ReplicatedStorage doesnt clone to player GUI when an image button is pressed. Help?

Hello. I am making a game, and in the game I have a team selection GUI which pops up when you join the game. After you select the team, the GUI is set to visible, because there are scripts inside which are needed. Anyways, the problem I am having is that I have another GUI that I want to pop up to a player that has chosen that team. Here is the example ; I join the game. I Join The Noobs Team. The GUI which I selected "Noobs" team from has now been set to Visible = false . Now I want the GUI in which the weapon selection options are. I have it Replicated Storage and in my script I try to :Clone() it then make the Parent of the GUI the PlayerGui . Where have I gone wrong and how can I fix it?

(This is a script in which I used in another place which I made a year ago, and it works fine)

local p = game.Players.LocalPlayer

game.StarterGui.Start.Start.Army.MouseButton1Down:Connect(function()
        if p.TeamColor.Name == "Maroon" then -- The team colour for Noobs is Maroon
            p:WaitForChild("PlayerGui")
            game.ReplicatedStorage.BaconArmy:Clone().Parent = p.PlayerGui

        p.CharacterAdded:Connect(function(character)
            game.ReplicatedStorage.BaconArmy:Clone().Parent = p.PlayerGui  
        end)

        end
    end)
 

I have this local script also which is in the Army button. Is there anything wrong with this that may be causing the clone not to show up on the clients screen?

local plr = game.Players.LocalPlayer --Easy way to refer to the client
local team = game.Teams.Noobs -- the team
local cam = game.Workspace.CurrentCamera -- not needed anymore but keep it ynot?
local cp = game.Workspace.CamPart -- i cba deleting

if plr:FindFirstChild("HasSelectedTeam") then --Check for the value
    script.Parent.Parent.Parent:Destroy() -- if the value is there, then destroy the frame
end

function onButtonClicked()
    plr.Character:BreakJoints() --Easy way to kill people
    plr.Team = team --The client's team has now been set to the team we made a variable of before
    Instance.new("BoolValue",plr).Name = "HasSelectedTeam"; --Insert value
    script.Parent.Parent.Visibe = false  --Instead of destroying it, it is set to invisible, because there are some valuable scripts inside
	script.Parent.Parent.Parent.Options:Destroy() -- destroy the options, don't need them
	
end

script.Parent.MouseButton1Down:connect(onButtonClicked)


2 comments

0

Maybe fix the way you made the script?

0

What do you mean?

1 answer

If you checked the output it would say nil to access localplayer

You can't use localscripts anymore.

4 comments

0

You can use LocalPlayer, but only from specific directories, e.g. from Workspace it wouldn't work.

0

so what should i do?

0

I have a local script in the army button, and thats the second script. so what should i do and how should i go about doing it. I want to destroy the frames as i don't want them popping up again. Like what script should I use and where should it be.

0

Actually your using it in a GUI it would work im pretty sure.

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