server:
local FightModule = require(game:GetService("ReplicatedStorage").FightModule)
local remote = game:GetService("ReplicatedStorage").Train
local NPC = script.Parent.Parent.Parent
script.Parent.Triggered:Connect(function(plr)
remote:FireClient(plr, NPC)
end)
client:
local FightModule = require(game:GetService("ReplicatedStorage").FightModule)
local remote = game:GetService("ReplicatedStorage").Train
remote.OnClientEvent:Connect(function(plr, npc)
FightModule.TrainFight(plr, npc)
end)
I was trying to sent the player and npc throught the remote event but im getting: Character is not a valid member of Model "Workspace.TRAINING.Nerd"
When using RemoteEvents, the server calls
remoteEvent:FireClient(player, a, b, c), but the client will only receive the arguments :remoteEvent.OnClientEvent(function(a, b, c) ...Your LocalScript code appears to be treating the first argument as the player, when it is actually the NPC sent from the server. Your LocalScript can get the Player object by using
game.Players.LocalPlayer.So try this :
I'm not sure what your FightModule does, but be careful if you're using it to increment leaderstats counters or anything like that. Changes made on the client will not be replicated back up to the server. If you need stat changes to be seen by all of your players, you might consider moving this code up into the server script.