Basically I have a local script that fires a remote event and the server script gets the player's mouse target. I try to then use the mouse target to fire the specific client. Even when I verify that the player exists in game.Players the script says it is Unable to cast a value to Object.
I've simplified the code to only show the FireClient() part of the script.
script.Parent:WaitForChild("ArrestPlayer").OnServerEvent:Connect(function(player, mouse_target) if game:GetService("Players"):FindFirstChild(mouse_target) then print("yes") game:GetService("ReplicatedStorage").GameEvents.Tools.ArrestCoreUI:FireClient(mouse_target) else print("no") end end)
and in the local script I use .Name so I have no idea why it wouldn't work?
local mouse_target = mouse.Target.Parent.Name script.Parent:WaitForChild("ArrestPlayer"):FireServer(mouse_target)
Any help would be appreceiated
FireClient
is a player to fire to.script.Parent:WaitForChild("ArrestPlayer").OnServerEvent:Connect(function(player, mouse_target) if game:GetService("Players"):FindFirstChild(mouse_target) then print("yes") game:GetService("ReplicatedStorage").GameEvents.Tools.ArrestCoreUI:FireClient( player, mouse_target ) else print("no") end end)
you need to specify the player in the :FireClient()