so i have a script that gonna start hit after activation but it not activates i tried a lot of things but it not worked script:
it not warns line 12
repeat wait() until script.Parent.Parent:IsA("Model")
local rs = game:GetService("ReplicatedStorage")
local tool = script.Parent
local raycast = require(rs:WaitForChild("Modules").RaycastHitboxV4)
local char = tool.Parent
local hitbox = raycast.new(char:WaitForChild("FakeLeg"))
hitbox.DetectionMode = raycast.DetectionMode.PartMode
warn("line 8")
local db = false
warn("line10")
script.Parent.Activated:Connect(function()
warn("line 12")
if db == false then
db = true
hitbox.OnHit:Connect(function(hit)
if hit.Parent.Name == "Floors" then
local health = hit:FindFirstChild("Health")
if health then
health.Value -= 20
end
end
end)
char.Humanoid:LoadAnimation(tool.Stomp):Play()
hitbox:HitStart(1)
wait(1)
db = false
end
end)
Any errors in the output? Are you sure this script is parented under the tool?
One possible reason for why the Activated event is not firing is because there is no handle in the tool. If this is true, insert a part (or any of its related classes such as MeshPart) under the tool and rename it to Handle.
I have rearranged a bit of your code, let me know if the print statements show in the output:
local rs = game:GetService("ReplicatedStorage")
local tool = script.Parent
local raycast = require(rs:WaitForChild("Modules").RaycastHitboxV4)
local db = false
print("created variables")
tool.Activated:Connect(function()
print("tool activated")
local char = tool.Parent
local hitbox = raycast.new(char:WaitForChild("FakeLeg"))
hitbox.DetectionMode = raycast.DetectionMode.PartMode
if not db then
db = true
hitbox.OnHit:Connect(function(hit)
if hit.Parent.Name == "Floors" then
local health = hit:FindFirstChild("Health")
if health then
health.Value -= 20
end
end
end)
char.Humanoid:LoadAnimation(tool.Stomp):Play()
hitbox:HitStart(1)
task.wait(1)
db = false
end
end)