Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Mouse.Target returns the player?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
uhSaxlra 181
4 years ago

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

event.OnServerEvent:Connect(function(playerInstance, target)
    target.Humanoid.Health = 0
end)
0
Ohhh, thanks so much! Utter_Incompetence 856 — 4y
Ad

Answer this question