Hi, I'm trying to make a a bat in my game, and it's supposed to knock back players when its ability is used. For some reason, it only works on dummies and not actual players. Does anyone know why? Help would be appreciated.
here is the script in server script service:
bat.Handle.hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= player.Name then
if debounce == false then
debounce = true
bat.Handle.BIGHIT:Play()
game.ReplicatedStorage.Boom:FireAllClients()
local boom1 = bat.Handle.hit1:Clone()
local boom2 = bat.Handle.hit2:Clone()
boom1.Parent = hit.Parent.HumanoidRootPart
boom2.Parent = hit.Parent.HumanoidRootPart
boom1.Enabled = true
boom2.Enabled = true
hit.Parent.HumanoidRootPart.Velocity = char.HumanoidRootPart.CFrame.LookVector * 300 + Vector3.new(0, 30, 0)
hit.Parent.Humanoid:TakeDamage(20)
wait(0.4)
boom1.Enabled = false
boom2.Enabled = false
wait(1)
boom1:Destroy()
boom2:Destroy()
end
end
end
end)
end)

21 comments
You can also use “FindFirstChildWhichIsA” because it also works and does the same way as “FindFirstChildOfClass”
Thanks for the answer, I'll see if it works!
Huh, for some reason it still doesn't work. I still doesnt knock the player back and still only works on the dummy. I replaced "if hit.parent:FindFirstChild("Humanoid") with if hit.Parent:FindFirstChildOfClass("Humanoid") do you know why?
I also tried with the other version.
Oh wait I think something is wrong to your script, I'll edit my answer rq
It still wont work?? Sorry I keep bugging you lol but ive needed to fix this for a while
Do you have a script in your bat tool? Have you used Tool.Activated in your tool? Maybe that’s the problem?
I won’t get mad if you keep bugging me lol. I just wanted to help people and get my answer accepted.
oh no, the script is inside of server script service. It happens when i remote event is fired from the bat
sorry for the confusion
wdym
can you send me a model of your tool and the script in your serverscriptservice? i might fix it myself
https://www.roblox.com/library/10117539864/help Heres the model with everything inside
Thank you
I’m almost done with the tool. I’ll send it to you tomorrow. I also notice your roblox profile and you have a game.
yes lol
just to clarify to use the ability is e, sorry i didnt say before
sorry for the delay, but i will send you the tool tomorrow. i delayed the fixing of the tool because of the new mimic update.
No worries, take all the time you need. I understand.
Done! I finished the bat tool and I edited the answer. You're welcome!
It finally works!! Thank you so much! I was kind of just wondering if you would mind maybe explaining it, but you dont have to. Just because I'm still fairly new to scripting and dont really understand what you did lol