Remote Event not working? Works in studio but not game
Asked by
6 years ago Edited 6 years ago
I made an object with a server script inside, a remote event inside player character scripts, and a remote event inside replicated Storage. The thing works inside studio, but In-game it says Fireclient argument must be a player object. Any ideas? Thank you. this is server script
03 | local plr = game:GetService( "Players" ).LocalPlayer |
04 | local Workspace = game:GetService( "Workspace" ) |
05 | local repSto = game:GetService( "ReplicatedStorage" ) |
08 | local fooPic = script.Parent |
09 | local AddValueEvent = repSto:WaitForChild( "FoodPickupEvent" ) |
12 | local function FireServerWhenTouched (hit, plr) |
13 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
15 | AddValueEvent:FireClient(plr) |
19 | fooPic.Touched:Connect(FireServerWhenTouched) |
23 | this is local script inside player |
27 | local player = game:GetService( "Players" ).LocalPlayer |
28 | local pgui = player:WaitForChild( "PlayerGui" ) |
29 | local repStore = game:GetService( "ReplicatedStorage" ) |
32 | local AddValueEvent = repStore:WaitForChild( "FoodPickupEvent" ) |
35 | local sg = pgui:WaitForChild( "ScreenGui" ) |
36 | local is = sg:WaitForChild( "InStats" ) |
37 | local foodAmm = is:WaitForChild( "FoodAmm" ) |
39 | local bp = player:WaitForChild( "Backpack" ) |
40 | local isf = bp:WaitForChild( "InvStats" ) |
41 | local accAmm = isf:WaitForChild( "FoodAmm" ) |
44 | local function ChangeMessageWhenFired() |
45 | accAmm.Value = (accAmm.Value + 1 ) |
46 | foodAmm.Text = accAmm.Value |
50 | AddValueEvent.OnClientEvent:Connect(ChangeMessageWhenFired) |
thank you