1 | function onTouched(hit) |
2 | p.Instance.New = ( "Player" ) |
3 | h.Instance.New = ( "Humanoid" ) |
4 | f.Instance.New = ( "Health" ) |
5 | p.h.f:remove() |
6 | end |
7 | 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:
1 | script.Parent.Touched:connect( function () |
2 | local p = Instance.new( "Part" ,Workspace) |
3 | wait( 3 ) |
4 | p:Destroy() |
5 | end ) |
EDIT:
Change the character's humanoid's health:
1 | script.Parent.Touched:connect( function (hit) |
2 | if Game.Players:GetPlayerFromCharacter(hit.Parent) then |
3 | hit.Parent:WaitForChild( "Humanoid" ):TakeDamage( 10 ) |
4 | end |
5 | end ) |