What is the issue? So i made a point system and whenever it reached 5 it locks you in 5 and u have to reset it through a part. the storage thingy works fine BUT after i reset it is not giving me points.
**What solutions have you tried so far?**I tried looking at the devhub, no solution : (
-- The point gaining script
script.GetStrength.OnServerEvent:Connect(function (player)
for i, item in ipairs(player.Ownedtools:GetChildren()) do
if item:IsA("Tool") then
local amount = item.Strength.Value
if player.leaderstats.Strength.Value >= tonumber(player.Storage.Value) then
player.leaderstats.Strength.Value = tonumber(player.Storage.Value)
script.Disabled = true
wait(1)
else if player.leaderstats.Strength.Value < tonumber(player.Storage.Value) then
script.Disabled = false
player.leaderstats.Strength.Value = player.leaderstats.Strength.Value + amount
end
end
end
end
end)
local Part= script.Parent
Part.Touched:Connect(function (Hit)
local H= Hit.Parent:FindFirstChild("Humanoid")
if H then
local player= game.Players:GetPlayerFromCharacter(Hit.Parent)
if player then
local leaderstats= player:WaitForChild("leaderstats")
local Currency= leaderstats.Coins
local Selling= leaderstats.Strength
if Selling.Value >= 0 then
Currency.Value =Currency.Value + Selling.Value*9999999
Selling.Value= 0
end
end
end
end)
This is an experiment so yes Also help me ASAP please and thank you!
The script won’t run if you disable it unless you enable it in another script but not in the script you want to disable, you should use break to stop a for loop.
local plr = game.Players.LocalPlayer
local leaderstats = plr:WaitForChild("leaderstats")
if leaderstats.Strength.Value < plr.Storage.Value then
script.Parent.MainEvents.Disabled = false
end
no , this is the script which enables the other script:
local plr = game.Players.LocalPlayer
local leaderstats = plr:WaitForChild("leaderstats")
if leaderstats.Strength.Value < plr.Storage.Value then
script.Parent.MainEvents.Disabled = false
end
Hello sorry for the late response but it shows me this error:
Workspace.bro:2: attempt to index nil with ‘leaderstats’
my script:
local player = game:GetService("Players").LocalPlayer
if player.leaderstats.Strength.Value >= tonumber(player.Storage.Value) then
player.leaderstats.Strength.Value = tonumber(player.Storage.Value)
script.Parent.MainEvents.Disabled = true
elseif player.leaderstats.Strength.Value < tonumber(player.Storage.Value) then
script.Parent.MainEvents.Disabled = false
end
local plr = game.Players.LocalPlayer
local leaderstats = plr:WaitForChild("leaderstats")
if leaderstats.Strength.Value < plr.Storage.Value then
script.Parent.MainEvents.enabled = false
well, i am not a good scripter, so i don’t know if it’s right.