Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

GUI button givving me weapons over and over again?

i press more than once and it gives me the weapons and if i press it gives me the weapons (again) so on, how do i fix this? there is two, the one for the button is this

 local player = game.Players.LocalPlayer 

script.Parent.MouseButton1Down:connect(
    function()
        game.ReplicatedStorage.RemoteEvent:FireServer(player)
    end
)

the script in the server replicated storage is

if game.Players.LocalPlayer.Backpack:FindFirstChild("weaponname") then
return
end

3 comments

0

uhh any code

0

... bruh

0

i didnt i re asked it

1 answer

Check if the weapon was already given. Server script:

local Weapon =  -- Tool
game.ReplicatedStorage.RemoteEvent:Connect(function(Player)
if Player.Backpack:FindFirstChild(Weapon.Name) ~= nil then
return
else
if Player.Character ~= nil then
	if Player.Character:FindFirstChild(Weapon.Name)  ~= nil then
		return
	end
end
Weapon:Clone().Parent = player.Backpack
end

13 comments

0

where do i put this? in the weapon code to give me the weapons?

0

Yes, before the line that gives you a weapon.

0

i have this but i dont have the ~= in it

0

Now there is updated serversided script.

0

where do i put this =(

0

cause i just put the code u posted bfore

0

It is server script.

0

Am i Supposed to have the . between the weapon names cause it didnt work

0

and the - - tool thing supposed to be the weapon name?

0

Weapon means the way to the weapon. Example: game.ReplicatedStorage.MyGun

0

--Tool is just a hint.

0

it didnt work, i think i didnt do any of it right

0

are you yhere still

This discussion is preserved as it was. New answers, comments, and votes are closed.