Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can Someone Ask Me what Is wrong With This Sword Kill Script And What i Should Add Or Remove?

Yeah So For This Place I Am Making.I Am Making A Sword Kill Script.But I Keep On Getting Errors.I Also Keep On Removing And Adding Things And It's Really Getting On My Nerves.Can Someone Carefully Look Through The Code And Point Out What I Have Done Wrong?

Here Is The Script:

if game.Parent.Player.Humanoid.Health == 0 then
	if game.Player.Sword == game.Sword.Parent then	 
		--Don't Know What I Am Doing Right Now
		game.Player.Sword.Parent (function(TouchedOn)
			if game.Sword.Player (TouchedOn) then
			   game.Player.Humanoid (TouchedOn)
			  game.Sword.Player.Humanoid (TouchedOn) .Health = 25 
			end
		end)
	end
end

1 answer

✓ Accepted answer

I dont think one line of your code is functional, but you can try using this outline instead:

script.Parent.Touched:Connect(function(hit)
	local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
	if hum then
		hum.Health = hum.Health - 25
	end
end)

This would need to be in the sword handle part.

4 comments

0

ok.I'll Put The Script In The Handle Part And Try That.

0

Thanks For The Answer.It Works And There Is No Errors.Though Next Time Can You Please Think About Whos Gonna Get Get Damaged.Because When My Character Picks It Up.He Loses 25HP.But Overall.Thanks Man,I Accept This Answer.

0

To make it where you can’t get damaged set a variable for script.Parent.Parent.humanoid and in the if statement right after hum out and not (variable you assigned to your humanoid) then. That should prevent your character from getting hit by it.

0

 youprevent your

This discussion is preserved as it was. New answers, comments, and votes are closed.