Please help me>>
Noobish scripter here
Please help me>>
Noobish scripter here
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Thanks but on Line06 what do i put in () Please give me an example!
You don't put anything in '()'
you can remove the "print" if you want, it affects nothing to the script its only give you some message/warnings in the output