I am finalizing my roblox story game but cant seem to get a really simple script working is there anyone who can help?
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Sword = script.Parent:WaitForChild("Sword")
local Slash = script:WaitForChild("Slash")
local Debounce = false
local Hitting = {}
Tool.Activated:Connect(function()
if Debounce == false then
Debounce = true
local Humanoid = Tool.Parent:FindFirstChild("Humanoid")
local AnimTrack = Humanoid:LoadAnimation(Slash)
AnimTrack:Play()
local sound2 = Instance.new("Sound")
sound2.PlayOnRemove = true
sound2.SoundId = "rbxassetid://147722227"
sound2.Volume = 1
sound2.TimePosition = 1
sound2:Destroy()
wait(1)
Debounce = false
end
end)
Sword.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= Tool.Parent then
if Debounce == true and Hitting[Hit.Parent] == nil then
if Hit.Parent:findFirstChild("ForceField") then
if Hit.Parent.ForceField.Visible == true then
return
end
end
Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health - 10
local sound = Instance.new("Sound",Hit.Parent)
sound.PlayOnRemove = true
sound.SoundId = "rbxassetid://4752240634"
sound.Volume = 1
sound.TimePosition = 1
sound:Destroy()
Hitting[Hit.Parent] = true
wait(1)
Hitting[Hit.Parent] = nil
end
end
end)
For context I want a hit sound and a swing sound, the sword cant damage any players in the server and only npcs in server. And when you hit a hit effect comes up sort of like this