-------------------------- --Script(ServerScriptService) local money = game:GetService("ServerStorage"):WaitForChild("PlayerMoney") local event = game:GetService("ReplicatedStorage").Events.CashGui event.OnServerEvent:Connect(function(PlayerText, Cash) money[PlayerText.Text].Value = money[PlayerText.Text].Value + Cash.Text end) -------------------------- -- LocalScript(gui) local plr = game:GetService("Players").LocalPlayer local event = game:GetService("ReplicatedStorage").Events.CashGui local money = game:GetService("ServerStorage"):WaitForChild("PlayerMoney") local Send = script.Parent.GiveCash function Smart() local PlayerText = script.Parent.PlayerText local Cash = script.Parent.CashText local plr = game:GetService("Players"):FindFirstChild(PlayerText.Text) if plr then event:FireServer(PlayerText, Cash) else print(PlayerText.Text.. " is Offline.") end end Send.MouseButton1Click:Connect(Smart)
Error:
--Text is not a valid member of Player
-- Script 'ServerScriptService.CashGUi', Line 6
The problem is that when you fire a remote event, you will always instantly receive a parameter for the player, no matter if you provide it as an argument or not. Therefore the roblox server is regarding your first parameter as the player and is causing your script to error. Here is the line you need to fix to make it work.
--Straight to line 6 event.OnServerEvent:Connect(function(player, PlayerText, Cash) --Change line 6 to this line and your script will be working just fine.