Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Mouse.Target returns the player?

So I'm trying to make a point-and-click type of weapon, and I use a RemoteEvent so it registers on the server, and in output, it returns " 19:07:25.915 - Humanoid is not a valid member of Player"

--Local Script
local player = game.Players.LocalPlayer
local character = player.Character

script.Parent.Equipped:Connect(function(mouse)
	mouse.Button1Down:Connect(function()
		if mouse.Target.Parent:FindFirstChild("Humanoid") then
			script.Parent.Attack:FireServer(mouse.Target.Parent)
		end
	end)
end)
--Script
local tool = script.Parent
local event = tool.Attack

event.OnServerEvent:Connect(function(target)
	target.Humanoid.Health = 0
end)

1 answer

✓ Accepted answer

The parameters for OnServerEvent include the player instance first, then the arguments.

event.OnServerEvent:Connect(function(playerInstance, target)
    target.Humanoid.Health = 0
end)

1 comment

0

Ohhh, thanks so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.