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 11 years ago

Please help me>>

Noobish scripter here

1 answer

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

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

1script.Parent.MouseButton1Click:connect(function()
2 
3end)

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

1if not game.Players.LocalPlayer.Backpack:FindFirstChild("Sword") then
2 
3end

and then give the player the item.

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

and if they already have it

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

so it should look like this in the end;

01--Put this in the image button
02--This must be a local script.
03script.Parent.MouseButton1Click:connect(function() --Clicked
04if not game.Players.LocalPlayer.Backpack:FindFirstChild("Sword") then   --If they dont already have the sword
05print("Giving "..game.Players.LocalPlayer.Name.." a sword.")
06Sword = game.ReplicatedStorage.Sword:Clone() --Clone the sword, change this to wherever your sword is.
07Sword.Parent = game.Players.LocalPlayer.Backpack --Parenting the newly cloned item
08elseif game.Players.LocalPlayer:FindFirstChild("Sword") then
09print(game.Players.LocalPlayer.Name.." Already received the sword.")
10end
11end)
0
Thanks but on Line06 what do i put in () Please give me an example! FPSStudioDidi 1 — 11y
0
You don't put anything in '()' drahsid5 250 — 11y
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 — 4y
Ad

Answer this question