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

how would i fix a script that gives u a gun after 10 kills?

Asked by
hokyboy 270 Moderation Voter
4 years ago
Edited 4 years ago
script.Parent.MouseButton1Click:Connect(function()
    if game.player.localplayer.leaderstats.kills >= 10 then do
 script.Parent.Parent.SCAR:Clone.Parent = game.Players.LocalPlayer.backpack
)

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

easy fix

script.Parent.MouseButton1Click:Connect(function()
    if game.Players.LocalPlayer.leaderstats.kills.Value >= 10 then
 script.Parent.Parent.SCAR:Clone().Parent = game.Players.LocalPlayer.Backpack
end
end)

this will only work if its a local script

0
the formatting e.e lunatic5 409 — 4y
0
also explain what you fixed and why they need to be fixed so he can learn from his mistake lunatic5 409 — 4y
0
cant be bothered right now, rather be reported or something, but i understand that you know what i fixed so why dont you explain Gameplayer365247v2 1055 — 4y
0
This isnt that good because youd have to add 10 to the cap after every time he reaches 10s value The_Pr0fessor 595 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Well you'd have to get the starting amount of kills and add ten to that.

local StartAmount = game.Players.LocalPlayer.leaderstats.kills

local Cap = 10

script.Parent.MouseButton1Click:Connect(function()
    if game.Players.LocalPlayer.leaderstats.kills >= Cap then
        Cap = Cap + 10
        --[[Gun Clone]].Parent = game.Players.LocalPlayer.Backpack
    end
end)

Client Sided ONLY ^

You most likely know how to use remote events but this is a way

local StartAmount = game.Players.LocalPlayer.leaderstats.kills

local Cap = 10
script.Parent.MouseButton1Click:Connect(function()
    if game.Players.LocalPlayer.leaderstats.kills >= Cap then
        GunChanger:FireEvent(game.Players.LocalPlayer.Backpack, OldGun)
        Cap = Cap + 10
    end
end)

Client Side^

KillChecker.OnServerEvent:Connect(function(Player, Backpack, OldGun) 
    OldGun:Destroy()
    NewGun:Clone().Parent = Backpack
end)

Server Side^

Answer this question