I am after someone who knows how to basically have a script, not a local script inside a button, that upon click if. the player who clicks, has say 100 kills then they can equip the ability “kinetic”
this is what I got, doesn’t work tho, as always
local plrs = game:GetService("Players")
script.Parent.MouseButton1Click:Connect(function(plr)
local player = plrs:GetPlayerFromCharacter(plr)
if player.leaderstats.Kills.Values >= 50 then
player.leaderstats.Ability.Value = "Kinetic"
end
end)
Btw it doesn’t work because this error is what appears:
“Attempt to index nil with leaderstats” on line 5
That basicly means it can’t find the leaderstats folder of the player. (I guess you create it in another script) But the real problem ist
You already get the player (plr) in the MouseButton1Click Funktion. So most likely player will be nil in your script. Try replacing player.leaderstats with plr.leaderstats
script.Parent.MouseButton1Click:Connect(function(plr)
local player = script:FindFirstAncestorOfClass("Player")
if player.leaderstats.Kills.Value >= 50 then
player.leaderstats.Ability.Value = "Diamond"
end
end)