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?
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)