Hi! I’m trying to make an animated NPC walk up to you when you enter a certain hitbox/area and then, it will fire an event showing a GUI. But, I’m getting an error saying “FireClient: player argument must be a Player object”.
Neither the event nor the NPC is moving to the area it’s supposed to. I’ve looked all over the dev forum and I can’t find a solution.
SERVERSCRIPT in NPC
local NPC = script.Parent
local part1= game.workspace.MaxPathFindWalk
local runanimation = NPC.Run
local idleanimation = NPC.Idle
local runanimationtrack = NPC.Humanoid:LoadAnimation(runanimation)
local idleanimationtrack = NPC.Humanoid:LoadAnimation(idleanimation)
local debounce = false
script.Parent.LockOn.Touched:Connect(function(hit)
if not debounce then
debounce = true
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.TrainerEvents.TrainerBattleTrigger:FireClient(plr)
--Walk to Targetted Part
idleanimationtrack:Play()
NPC.Humanoid:MoveTo(game.Workspace.MaxPathFindWalk.Position)
idleanimationtrack:Stop()
runanimationtrack:Play()
NPC.Humanoid.MoveToFinished:Wait()
idleanimationtrack:Play()
end
wait(5)
debounce = false
end)
--Finish walking to targetted part
I think the problem is in the :GetPlayerFromCharacter. :GetPlayerFromCharacter function returns the Player associated with the given Player.Character , or nil. However, the plr that u r trying to pass in the :FireClient is not a player.