Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

InstantManager is not a valid member of Players?

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

✓ Accepted answer

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

1 comment

0

thx :)

This discussion is preserved as it was. New answers, comments, and votes are closed.