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

GUI button givving me weapons over and over again?

Asked by 4 years ago
Edited by Leamir 4 years ago

Please do not repost your question after it has been closed.

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

0
uhh any code Pupppy44 671 — 4y
0
... bruh ScottRulesAtAnything -1 — 4y
0
i didnt i re asked it ScottRulesAtAnything -1 — 4y

1 answer

Log in to vote
0
Answered by
Accoast 43
4 years ago
Edited 4 years ago

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
0
where do i put this? in the weapon code to give me the weapons? ScottRulesAtAnything -1 — 4y
0
Yes, before the line that gives you a weapon. Accoast 43 — 4y
0
i have this but i dont have the ~= in it ScottRulesAtAnything -1 — 4y
0
Now there is updated serversided script. Accoast 43 — 4y
View all comments (9 more)
0
where do i put this =( ScottRulesAtAnything -1 — 4y
0
cause i just put the code u posted bfore ScottRulesAtAnything -1 — 4y
0
It is server script. Accoast 43 — 4y
0
Am i Supposed to have the . between the weapon names cause it didnt work ScottRulesAtAnything -1 — 4y
0
and the - - tool thing supposed to be the weapon name? ScottRulesAtAnything -1 — 4y
0
Weapon means the way to the weapon. Example: game.ReplicatedStorage.MyGun Accoast 43 — 4y
0
--Tool is just a hint. Accoast 43 — 4y
0
it didnt work, i think i didnt do any of it right ScottRulesAtAnything -1 — 4y
0
are you yhere still ScottRulesAtAnything -1 — 4y
Ad

Answer this question