So my tool requires that I touch the target for an extended period of time to work, and I’m not quite sure why. I want it to damage them the first time I make contact with them. At first I thought the issue might be that the part making contact was too small, and therefore was not making contact correctly. To remedy this, I tried making a transparent part to register the hit instead, and that still did not work.
Local script:
local player = game:GetService("Players").LocalPlayer
local animation = script.Parent:WaitForChild("NarutoRasenganAnimation")
local debounce = false
script.Parent.Activated:Connect(function()
if not debounce then
debounce = true
local AnimationTrack = player.Character.Humanoid:LoadAnimation(animation)
AnimationTrack:Play()
script.Parent.RasenganActivate:FireServer()
wait(30)
debounce = false
end
end)
Relevant portion of Server Script:
script.Parent.handle.Touched:Connect(function(hit)
if hit.Parent ~= player.Character and hit.Parent:FindFirstChild("Humanoid") then
if not debounce then
debounce = true
hit.Parent.Humanoid.Health -= 30
local boomSound = ServerStorage.Sounds.BoomSound:Clone()
boomSound.Parent = script.Parent.Parent
boomSound:Play()
wait(3)
boomSound:Destroy()
debounce = false
end
end
end)
Video of occurrence:
robloxapp-20210315-2103580.wmv (1.7 MB)
1 Like
I mean, you could just make it into 1 entire Server Script & do the code that way if it works better? Just put the Touched
event inside the Activated
event on a Server Script to see if that’s quicker?
So I converted it all into a server script and the exact thing still happens (I should have assigned script.Parent.Parent to a character variable to improve readability but I was in a rush to see if this would fix the issue).
local ServerStorage = game:GetService("ServerStorage")
local debounce = false
local weld
local rasenganHoldingAnimation = script.Parent:WaitForChild("NarutoRasenganHoldingAnimation")
local animation = script.Parent:WaitForChild("NarutoRasenganAnimation")
script.Parent.Activated:Connect(function()
script.Parent.Parent.Rasengan.handle.Transparency = 0.3
script.Parent.Parent.Rasengan.Part.Transparency = 0.3
local narutoClone = ServerStorage.Characters.Naruto:Clone()
narutoClone.Parent = workspace
narutoClone.Name = "Naruto"
local narutoCloneCFrame = (script.Parent.Parent.PrimaryPart.CFrame:ToWorldSpace(CFrame.new(5, 0, -4)))
narutoCloneCFrame = CFrame.lookAt(narutoCloneCFrame.Position, script.Parent.Parent.PrimaryPart.Position)
narutoClone:SetPrimaryPartCFrame(narutoCloneCFrame)
local rasenganNarutoCloneAnimation = narutoClone.RasenganNarutoCloneAnimation
script.Parent.Parent.Humanoid.WalkSpeed = 0
local jutsuSound = ServerStorage.Sounds.JutsuSound:Clone()
jutsuSound.Parent = script.Parent.Parent
jutsuSound:Play()
local animationTrackRasengan = script.Parent.Parent.Humanoid:LoadAnimation(animation)
animationTrackRasengan:Play()
local animationTrackRasenganNarutoCloneAnimation = narutoClone.Humanoid:LoadAnimation(rasenganNarutoCloneAnimation)
animationTrackRasenganNarutoCloneAnimation:Play()
wait(3)
jutsuSound:Destroy()
local poofSound = ServerStorage.Sounds.PoofSound:Clone()
poofSound.Parent = script.Parent.Parent
poofSound:Play()
narutoClone:Destroy()
local animationTrackRasenganHolding = script.Parent.Parent.Humanoid:LoadAnimation(rasenganHoldingAnimation)
animationTrackRasenganHolding:Play()
script.Parent.Parent.Humanoid.WalkSpeed = 40
wait(5)
poofSound:Destroy()
script.Parent.Parent.Humanoid.WalkSpeed = 16
script.Parent.Parent.Rasengan.handle.Transparency = 1
script.Parent.Parent.Rasengan.Part.Transparency = 1
script.Parent.handle.Touched:Connect(function(hit)
if hit.Parent ~= script.Parent.Parent and hit.Parent:FindFirstChild("Humanoid") then
if not debounce then
debounce = true
hit.Parent.Humanoid.Health -= 30
local boomSound = ServerStorage.Sounds.BoomSound:Clone()
boomSound.Parent = script.Parent.Parent
boomSound:Play()
wait(3)
boomSound:Destroy()
debounce = false
end
end
end)
end)
script.Parent.Equipped:Connect(function()
local partToFix = script.Parent.handle
weld = Instance.new("ManualWeld", partToFix)
weld.Part0 = script.Parent.Parent["Right Arm"]
weld.Part1 = partToFix
weld.C0 = CFrame.new(0,-1.5,0)
end)
script.Parent.Unequipped:Connect(function()
weld:Destroy()
end)
Try printing out a couple statements inside & outside the Touched
event
1 Like
Thank you for that piece of advice, I always forget to check things like that with prints. It was the issue of the touched event being after the 5 second wait on the end and not before.
1 Like
Yeaaah, you should always make sure that your script fully works by debugging it with print()
statements before posting here Glad you were able to fix it though!
1 Like