I have a simple issue: [Attempt to index local player
(a nil value)].
Its Line 7 or
[local leaderstats = player:WaitForChild(“leaderstats”)]
The error Fires immediately and not when the function is called
FYI This is a Shop-Script, this is the server-side.
local storage = game:GetService("ReplicatedStorage")
local remote = storage:WaitForChild("ShopFunction")
local Players = game:GetService("Players")
local function ShopBuy(player,Object,Level)
--Variables
local leaderstats = player:WaitForChild("leaderstats")
local gold = leaderstats.Gold.Value
local rank = leaderstats.Rank.Value
local Clevel = leaderstats.CannonLevel.Value
local Slevel = leaderstats.ShipLevel.Value
--Variables
----Ship
if Object == "Ship" then
if Level == 1 then
--Level1
if gold >= 0 and
rank >= 0 and
Slevel == 0 then
gold = gold-0
Slevel = 1
end
---More Stuff like this ^^^^^^^ (This is a shop script)
end
end
local player
local Object
local Level
remote.OnServerEvent:Connect(ShopBuy(player,Object,Level))
I basically copied from my click detector script but obviously that never worked.
local but = script.Parent.Parent.StartButton
but.ClickDetector.MouseClick:Connect(function(plr)
local leader = plr:FindFirstChild("leaderstats")
local shipl = leader.ShipLevel
local cannonl =leader.CannonLevel
Any help is appreciated thanks.