Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

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

Asked by 9 years ago

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

0
Do you know how to damage a humanoid at least? Tkdriverx 514 — 9y
0
When scripting the sword simply make it deal 100 damage. Perci1 4988 — 9y
0
Now I know how to do it. raikage488 0 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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 --
Ad

Answer this question