You know what i will make it easier for you but you have to know that you need to change the name of the ScreenGui
local Shop = script.Parent.Parent.Parent
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
local button = Shop.Shop.Sword1
local Kills = stats.Kills
Kills.Changed:Connect(function()
if Kills.Value >= 5 then
Shop.Shop.Sword1.Text = "Equip"
button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.GetSword:FireServer("AzureSword", script.Parent)
end)
end
end)
-- to check once the player enters
if Kills.Value >= 5 then
Shop.Shop.Sword1.Text = "Equip"
button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.GetSword:FireServer("AzureSword", script.Parent)
end)
end
You dont need to change the name with this one but the reason the others werent working was you didnt change the name of the screengui
local Shop = game.Players.LocalPlayer.PlayerGui:WaitForChild("Shop")
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
local button = Shop.Shop.Sword1
local Kills = stats.Kills
local RemoteFunction = game.ReplicatedStorage.RemoteFunction
button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteFunction:InvokeServer(Kills)
if RemoteFunction == true then
game.ReplicatedStorage.GetSword:FireServer("AzureSword", script.Parent)
else
return false
end
end)
then make a remote function in replicated storage
then paste the server code
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(plr, Kills)
if Kills.Value >= 5 then
return true
else
return false
end
end