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

Why is this script not working???

Asked by
IcyEvil 260 Moderation Voter
11 years ago
1function onTouched(hit)
2    p.Instance.New = ("Player")
3    h.Instance.New = ("Humanoid")
4    f.Instance.New = ("Health")
5p.h.f:remove()
6end
7script.Parent.touched:connect(onTouched)

Im new to scripting and I have been messing around with scripts similar to any that I attempt to make I can (attempt) to convert and sometimes I succeed but most the time I don't I found scripts similar to this and I wanted to try to make my own version so Could someone please help me figure out what i'm doing wrong?

0
Better question: What _are_ you doing? MrNicNac 855 — 11y
0
Trying to make a damage health script IcyEvil 260 — 11y

1 answer

Log in to vote
3
Answered by 11 years ago

You can't make a new instance of a "Player","Humanoid", or "Health".

Try this:

1script.Parent.Touched:connect(function()
2local p=Instance.new("Part",Workspace)
3wait(3)
4p:Destroy()
5end)

EDIT:

Change the character's humanoid's health:

1script.Parent.Touched:connect(function(hit)
2if Game.Players:GetPlayerFromCharacter(hit.Parent) then
3hit.Parent:WaitForChild("Humanoid"):TakeDamage(10)
4end
5end)
0
Im trying to damage a players health... But thanks :D Much appreciated IcyEvil 260 — 11y
0
Oh okay, let me edit my answer then. I didn't understand what you were trying to do so I just gave you a correct example of Instance.new(). TheGuyWithAShortName 673 — 11y
Ad

Answer this question