I'm making an Undertale game. And for the undyne fight, I made the shield she gives you in the game.
I tried to use the .Touched event with :FindFirstChild() to identify if the spear hit the shield. That didn't work because it couldn't find the shield. Then I just changed it to just the .Touched event. And that did actually destroy the spear. But it won't kick the player when the player touches it.
Heres my code:
Spear.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local Player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
Player:Kick("Pathetic...")
end
Spear:Destroy()
end)

1 comment
Try putting Spear:Destroy() inside of the if humanoid statement so it will destroy it only if the hit is actual human.