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 5 years ago
Edited 5 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"

01--Local Script
02local player = game.Players.LocalPlayer
03local character = player.Character
04 
05script.Parent.Equipped:Connect(function(mouse)
06    mouse.Button1Down:Connect(function()
07        if mouse.Target.Parent:FindFirstChild("Humanoid") then
08            script.Parent.Attack:FireServer(mouse.Target.Parent)
09        end
10    end)
11end)
12--Script
13local tool = script.Parent
14local event = tool.Attack
15 
16event.OnServerEvent:Connect(function(target)
17    target.Humanoid.Health = 0
18end)

1 answer

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

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

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

Answer this question