I’m trying to make a script for a tool which fires a part that insta kills anyone who get hits by it. Everything works fine apart from the kill script. For some reason an error message is produced reading “Humanoid is not a valid member of MeshPart”. I have no idea why this is the case.
local repStor = game:GetService("ReplicatedStorage")
local bullet = repStor.Part
local Tool = script.Parent
local tolly = script.Parent.Handle
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local newBullet = bullet:Clone()
Tool.Activated:Connect(function()
newBullet.Position = tolly.Position
newBullet.Parent = game.Workspace
newBullet.Velocity = mouse.Hit.LookVector * 1000
end)
newBullet.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Humanoid.Health = 0
end
end)