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
10 years ago
function onTouched(hit)
    p.Instance.New = ("Player")
    h.Instance.New = ("Humanoid")
    f.Instance.New = ("Health")
p.h.f:remove()
end
script.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 — 10y
0
Trying to make a damage health script IcyEvil 260 — 10y

1 answer

Log in to vote
3
Answered by 10 years ago

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

Try this:

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

EDIT:

Change the character's humanoid's health:

script.Parent.Touched:connect(function(hit)
if Game.Players:GetPlayerFromCharacter(hit.Parent) then
hit.Parent:WaitForChild("Humanoid"):TakeDamage(10)
end
end)
0
Im trying to damage a players health... But thanks :D Much appreciated IcyEvil 260 — 10y
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 — 10y
Ad

Answer this question