✓ Accepted answer
On line 12 you send 'hit' which should be the limb part of a character. Since you want to damage the humanoid and you defined a humanoid in line 09 then why not just send that?
script.Parent.Handle.Touched:Connect(function(hit)
hum = hit.Parent:FindFirstChildOfClass("Humanoid")
if hum then
script.Parent.Handle.Script.Disabled = false
script.Parent.Damage:FireServer(hum)
script.Parent.candama.Value = true
end
end)
The other issue in the same code above is line 06 where you set candama to true. The issue with this is that you're setting this on the client which wont replicate to the server. In the server script, the code probably still sees this BoolValue as false since it didn't replicate. Disabling the script here on line 04 also falls under this problem.
You could try removing this line and the if-statement in the server script but still might lack some security.
In the local script change the Touched event to this:
script.Parent.Handle.Touched:Connect(function(hit)
hum = hit.Parent:FindFirstChildOfClass("Humanoid")
if hum then
script.Parent.Damage:FireServer(hum)
end
end)
Then you would change the server script to:
script.Parent.Parent.Damage.OnServerEvent:Connect(function(player, humanoid)
if humanoid then
humanoid:TakeDamage(20)
end
end)
Let me know if you understood what I said or if I missed anything.
Edit: Make sure to also have a check to make sure hit isn't the player holding the tool! A few things left out which I can add in later if you need it.
Make sure the script that fires the remote event is a local script in the tool:
script.Parent.Activated:Connect(function()
if not bussy then
bussy = true
aims.slash:Play()
script.Parent.Handle.Touched:Connect(function(hit)
local target = hit.Parent:FindFirstChildOfClass("Humanoid")
if target then
script.Parent.Damage:FireServer(target)
end
end)
end
wait(2)
bussy = false
end)
3 comments
it dint work
i mad e a model of it https://www.roblox.com/catalog/02816042571/redirect
I looked at the model and it seems it was setting the LocalPlayer's Humanoid to the target humanoid. I provided fixed code at the bottom which basically makes a new local variable for the target humanoid.