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

Why is this script not working???

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?

2 comments

0

Better question: What are you doing?

0

Trying to make a damage health script

1 answer

✓ Accepted answer

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)

2 comments

0

Im trying to damage a players health... But thanks :D Much appreciated

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().

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