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

How make a script that you clicked a Image Button in a gui and then it gives you a weapon?

Asked by 10 years ago

Please help me>>

Noobish scripter here

1 answer

Log in to vote
2
Answered by
drahsid5 250 Moderation Voter
10 years ago

This is simple. First, you start with the click function;

script.Parent.MouseButton1Click:connect(function()

end)

then you should check if the player already has the item.

if not game.Players.LocalPlayer.Backpack:FindFirstChild("Sword") then

end

and then give the player the item.

print("Giving "..game.Players.LocalPlayer.Name.." a sword.")
Sword = game.ReplicatedStorage.Sword:Clone() --Clone the sword, change this to wherever your sword is.
Sword.Parent = game.Players.LocalPlayer.Backpack --Parenting the newly cloned item

and if they already have it

elseif game.Players.LocalPlayer:FindFirstChild("Sword") then
print(game.Players.LocalPlayer.Name.." Already received the sword.")

so it should look like this in the end;

--Put this in the image button
--This must be a local script.
script.Parent.MouseButton1Click:connect(function() --Clicked
if not game.Players.LocalPlayer.Backpack:FindFirstChild("Sword") then   --If they dont already have the sword
print("Giving "..game.Players.LocalPlayer.Name.." a sword.")
Sword = game.ReplicatedStorage.Sword:Clone() --Clone the sword, change this to wherever your sword is.
Sword.Parent = game.Players.LocalPlayer.Backpack --Parenting the newly cloned item
elseif game.Players.LocalPlayer:FindFirstChild("Sword") then
print(game.Players.LocalPlayer.Name.." Already received the sword.")
end
end)
0
Thanks but on Line06 what do i put in () Please give me an example! FPSStudioDidi 1 — 10y
0
You don't put anything in '()' drahsid5 250 — 9y
0
you can remove the "print" if you want, it affects nothing to the script its only give you some message/warnings in the output WhazANoobz 0 — 3y
Ad

Answer this question