This is simple.
First, you start with the click function;
1 | script.Parent.MouseButton 1 Click:connect( function () |
then you should check if the player already has the item.
1 | if not game.Players.LocalPlayer.Backpack:FindFirstChild( "Sword" ) then |
and then give the player the item.
1 | print ( "Giving " ..game.Players.LocalPlayer.Name.. " a sword." ) |
2 | Sword = game.ReplicatedStorage.Sword:Clone() |
3 | Sword.Parent = game.Players.LocalPlayer.Backpack |
and if they already have it
1 | elseif game.Players.LocalPlayer:FindFirstChild( "Sword" ) then |
2 | print (game.Players.LocalPlayer.Name.. " Already received the sword." ) |
so it should look like this in the end;
03 | script.Parent.MouseButton 1 Click:connect( function () |
04 | if not game.Players.LocalPlayer.Backpack:FindFirstChild( "Sword" ) then |
05 | print ( "Giving " ..game.Players.LocalPlayer.Name.. " a sword." ) |
06 | Sword = game.ReplicatedStorage.Sword:Clone() |
07 | Sword.Parent = game.Players.LocalPlayer.Backpack |
08 | elseif game.Players.LocalPlayer:FindFirstChild( "Sword" ) then |
09 | print (game.Players.LocalPlayer.Name.. " Already received the sword." ) |