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

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

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

✓ Accepted answer

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

4 comments

0

the formatting e.e

0

also explain what you fixed and why they need to be fixed so he can learn from his mistake

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

0

This isnt that good because youd have to add 10 to the cap after every time he reaches 10s value

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^

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