Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

InstantManager is not a valid member of Players?

Asked by 6 years ago

Here, I'm trying to make a gui that you put the player's name in the first textbox, and put the cash in the second textbox. After that, you click a button and then you add the cash to the player's leaderstats. I'm trying to do this but this keeps showing up. Help?

Use both scripts if needed for some odd reason:

--SERVER SCRIPT--

game.Players.PlayerAdded:Connect(function(plr)

local RS = game:GetService("ReplicatedStorage")
local twigger = RS.OwnerRemotes:WaitForChild("CashFrame")

twigger.OnServerEvent:Connect(function(plr, plrname, cash)
    if game.Players:FindFirstChild(plrname) then
    game.Players(plrname).leaderstats.Cash.Value = game.Players(plrname).leaderstats.Cash.Value + (cash) -- The problem/error
    end
end)
end)
--LOCAL SCRIPT--

local RS = game:GetService("ReplicatedStorage")
local remotea = RS.OwnerRemotes:WaitForChild("CashFrame")

script.Parent.CB.MouseButton1Click:Connect(function()

    local yeet = script.Parent.userBox.Text
    local yeeter = script.Parent.cashBox.Text

remotea:FireServer(yeet, yeeter)
end)

1 answer

Log in to vote
0
Answered by
aazkao 787 Moderation Voter
6 years ago
Edited 6 years ago

You used the wrong bracket to get the player from game.Players, it is supposed to be "[]"

game.Players[plrname]

or you could also use FindFirstChild

0
thx :) InstantManager 27 — 6y
Ad

Answer this question