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

How to make a weapon do a insta-kill damage?

I cant make a script on making a sword when used to kill someone do a 100 damage

3 comments

0

Do you know how to damage a humanoid at least?

0

When scripting the sword simply make it deal 100 damage.

0

Now I know how to do it.

1 answer

It's very simple. All you need to do is get the Workspace, this can be done two ways:

workspace

-- or --

game.Workspace

Once you have the Workspace, you just need to find the player. Let's say for example your gun has a hit function, then you'd find the Hit's Parent's Name. But, how do you find the player? Well, it's simple. We use the FindFirstChild function:

workspace:FindFirstChild(hit.Parent.Name)

Now we need to deal the damage, we do this by accessing the Humanoid object. The humanoid is what holds your walkspeed, health, and maxHealth. We can access all these properties by getting the humanoid:

workspace:FindFirstChild(hit.Parent.Name).Humanoid

Now all we need is the Health property from the Humanoid:

workspace:FindFirstChild(hit.Parent.Name).Humanoid.Health

Now just set it's value to 0 by typing " = 0 ". Whole script:

workspace:FindFirstChild(hit.Parent.Name).Humanoid.Health = 0; -- The Semi-Colon is optional --

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