Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

GUI button givving me weapons over and over again?

Asked by 3 months ago
Edited by Leamir 3 months 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 — 3mo
0
... bruh ScottRulesAtAnything -1 — 3mo
0
i didnt i re asked it ScottRulesAtAnything -1 — 3mo

1 answer

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

Answer this question