I have a remote event that fires to the client and i'm trying to fire the player but for some reason the player is taking the role of the numberamnt
local box = script.Parent local stat = game.ReplicatedStorage.Remote.StatUpd local function PlayerTouched(Part) local Parent = Part.Parent if game.Players:GetPlayerFromCharacter(Parent) then local plr = game.Players[Parent.Name] local moneyamnt = math.random(200,400) stat:FireClient(plr, moneyamnt) end end box.Touched:connect(PlayerTouched)
^^^ The script firing the client (Not a local script)
local stat = game.ReplicatedStorage.Remote.StatUpd stat.OnClientEvent:Connect(function(plr, moneyamnt) plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + moneyamnt.Value end)
^^^ The script receiving what the client fires
plr
parameter. The OnClientEvent
event doesn’t pass the player as a parameter. Remove it. Also, you shouldn’t be giving money through the client, as this gives the client power. Never trust the client.stat.OnClientEvent.Connect(function(money)
plr is just a name, you need to do game.Players[plr].leaderstats etc, unless you can fire objects with fireclient which in that case just make plr = game.Players:GetPlayerFromCharacter(Parent). Not sure if possible. Also don't do moneyamnt.Value, moneyamnt is just a number.