0

# GUI not giving tool upon click, but GUI is displayed and can be clicked?

Asked by 8 years ago

Made a gui that when you click it, it will give your player that specific gear. Not working and followed the syntax errors? Mind if anyone take a look? I put the gear in server storage and referenced it correctly.

-- In a LocalScript in StarterGui:

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

-- Create TextButton
local textButton = Instance.new("TextButton")
textButton.Parent = screenGui
textButton.Position = UDim2.new(0, 50, 0, 50)
textButton.Size = UDim2.new(0, 140, 0, 60)
textButton.TextColor3 = BrickColor.White().Color
textButton.Style = 2
textButton.Text = "Marksman"

-- Bind function to button click
textButton.MouseButton1Click:connect(function(part)
p = game.Players:GetPlayerFromCharacter(part.Parent)
if p == nil then return end
bow = game.ServerStorage.SnowAndArrow:clone()
if p.Backpack:FindFirstChild(bow.Name) ~= nil then return end
bow.Parent = p.Backpack
end)


Do i have to put another end or? I just started scripting two weeks ago so pardon my stupidity but if you do really know how to fix it it would be nice to show it and how you did it so i can progress more in learning this language!

0
Answered by 8 years ago

On line 17 where it says: MouseButton1Click, It needs to be MouseButton1Down. And also, you need to make an on-clicked function:

function onClicked()
-- what ever you want to happen here
end
textButton.MouseButton1Down:connect(onClicked)

0
ok i see thank you and for where it says end what would i do there would i put two ends or remove the paranthese or???? gigabite176 20 — 8y