Local script
--Variabili
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local buco = script.Parent:FindFirstChild("Buco")
local tool = script.Parent
local evento = game:GetService("ReplicatedStorage"):FindFirstChild("Sparo")
local raggio = game.StarterPack.Tool.raggio.Value
--Funzione
tool.Equipped:Connect(function()
mouse.Button1Down:Connect(function()
print("Click")
local ray = Ray.new(buco.CFrame.p, (mouse.Hit.p - buco.CFrame.p) * raggio) --Crea il raggio
local bersaglio, position = workspace:FindPartOnRay(ray, player.Character)
if bersaglio then
local humanoid = bersaglio.Parent:FindFirstChild("Humanoid")
if humanoid then
evento:FireServer(player, bersaglio, humanoid)
end
end
end)
end)
Server script
local danno = game.StarterPack.Tool.danno.Value
local evento = game:GetService("ReplicatedStorage"):FindFirstChild("Sparo")
evento.OnServerEvent:Connect(function(player, bersaglio, humanoid)
print(player, bersaglio, humanoid)
if bersaglio.Name == "Head" then
humanoid:TakeDamage(danno * 2) else
humanoid:TakeDamage(danno)
end
end)
Output
Click
bucaniere bucaniere Right Arm
21:12:40.251 - TakeDamage is not a valid member of Part
Hello. This is my second post. I am having trouble with the humanoid which in the output is said to be a Part. Can anyone help me solve this issue? The comments and the variables are in Italian so I can understand them better, fell free to ask for the translated scripts if needed. Sorry if this question sounds silly but as I said in my previous post, I'm still learning. Thanks in advance.

1 comment
Thanks. That solved my problem.