Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why doesnt this gui work?

Asked by
theCJarmy7 1293 Moderation Voter
9 years ago

i have a gui that is supposed to give me an item called good build which is in ReplicatedStorage. Can you point out whats wrong here? I looked, and couldn't find anything.

local screenGui = Instance.new("ScreenGui")
screenGui.Parent = script.Parent

local textButton = Instance.new("TextButton")
textButton.Parent = screenGui
textButton.Position = UDim2.new(0, 300, 0, 650)
textButton.Size = UDim2.new(0, 150, 0, 100)
textButton.BackgroundColor3 = BrickColor.White().Color
textButton.Style = 3
textButton.Text = "builder"
textButton.MouseButton1Down:connect(function()

end)
        if not game.Players.LocalPlayer.Backpack:FindFirstChild("good build") then
            print("Giving "..game.Players.LocalPlayer.Name.." the builder.")
            good = game.ReplicatedStorage:FindFirstChild("good build"):Clone()
            good = good_build.Parent = game.Players.LocalPlayer.Backpack
        elseif game.Players.LocalPlayer:FindFirstChild("good build") then
            print(game.Players.LocalPlayer.Name.." You dont need it.")
        end
0
Is this a LocalScript? It needs to be. Also, put your code inside the function, not outside of it. TheDeadlyPanther 2460 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Your issue is that when a player clicks the Gui, your function works fine but you don't have anything for it to do!

Debugging

Make sure to debug and read through your scripts, as for yourself you simply misplaced the end) just with a bit of care and time you should've noticed it. If nothing shows on the output then go through the script line by line. I tend to add print("1"), print("2") and so on, so I know where my script is breaking.

Also rather than doing game.ReplicatedStorage, I suggest doing:

local game:GetService("Replicated Storage")

Conclusion

local game:GetService("Replicated Storage")

local screenGui = Instance.new("ScreenGui")
screenGui.Parent = script.Parent

local textButton = Instance.new("TextButton")
textButton.Parent = screenGui
textButton.Position = UDim2.new(0, 300, 0, 650)
textButton.Size = UDim2.new(0, 150, 0, 100)
textButton.BackgroundColor3 = BrickColor.White().Color
textButton.Style = 3
textButton.Text = "builder"

textButton.MouseButton1Down:connect(function()
        if not game.Players.LocalPlayer.Backpack:FindFirstChild("good build") then
            print("Giving "..game.Players.LocalPlayer.Name.." the builder.")
            good = ReplicatedStorage:FindFirstChild("good build"):Clone()
            good = good_build.Parent = game.Players.LocalPlayer.Backpack
        elseif game.Players.LocalPlayer:FindFirstChild("good build") then
            print(game.Players.LocalPlayer.Name.." You dont need it.")
        end
end)
Ad

Answer this question