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

How to have a script execute at a certain amount in Leader stats?

For example if you get 10 kills I want it to execute the script

2 comments

0

Any script..?

0

Please post some code so it is easier for us to help you fix it, this is help site not a request site.

2 answers

local Players = game:GetService("Players")
 
function onPlayerAdded(player)
kills = player.leaderstats.[Stat's name here, no brackets]
if kills == 10 then

[Remove this part and these brackets and insert your script here]

end

Next time your asking for something.

EXPLAIN YOURSELF.

Not just a simple "i wunt dut wun i hav 10 keels a scrept hoopans"

No, you need to say stuff like.

"I want that when my leaderstat value "kills" gets into a certain value, a script gets triggered, There is the script i want to get triggered:"

INSERT YOUR FLIPPING SCRIPT HERE.

1 comment

0

That will not work. Not even close. Local variables are long deprecated.

_G.char = game.Players.LocalPlayer.Character
game.Players.PlayerAdded:Connect(function()
	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"
	stats.Parent = char.Backpack
	local kills = Instance.new("IntValue")
	kills.Name = "Kills"
	kills.Parent = stats
	kills.Value = 0
end)
if char.Backpack:FindFirstChild("Kills") ~= nil then
	k = char.Backpack:FindFirstChild("Kills")
	if k.Value >= 10 then
		if game.Workspace.TriggerScript.Disabled ~= false then -- What could be the script that fires
			game.Workspace.TriggerScript.Disabled = false
		end
	end
end

Is this what you're talking about?

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