Extasio
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 3910 |
|
|
| 02 Jul 2016 11:57 PM |
function onTouch() game.Workspace.IDONTWANTPLAYER1.Head:Remove() --S.O.S script.Disabled=true wait(1) script.Disabled=false end script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
Extasio
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 3910 |
|
| |
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 03 Jul 2016 12:02 AM |
connecting a function to a Touched event gives you a parameter of the part that touched it:
function onTouch(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if player ~= nil then player.Character.Head:Destroy() end end
script.Parent.Touched:connect(onTouch)
using GetPlayerFromCharacter() is probably the best way to see if the object that touched the part belongs to a player, and I don't understand why you're disabling/enabling the script
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:02 AM |
GTYHUNJMKL<::dasdsadawacs
function onTouch(hit) if hit.Parent:findFirstChild("Head") then hit.Parent.Head:Remove() --S.O.S script.Disabled=true wait(1) script.Disabled=false end end script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
pullman45
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 2891 |
|
|
| 03 Jul 2016 12:02 AM |
| So you want to remove the head right? |
|
|
| Report Abuse |
|
|
pullman45
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 2891 |
|
| |
|
|
| 03 Jul 2016 12:05 AM |
Here if you want to save resources.
function onTouch(hit) for _,v in pairs(workspace:GetChildren()) do if v == hit.Parent then for _,x in pairs (v:GetChildren()) do if x:IsA("Part") then if x.Name == "Head" then x.Parent = game.Lighting script.Disabled=true wait(1) script.Disabled=false end end end end end end script.Parent.Touched:connect(onTouch)
|
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:06 AM |
script.Parent.Touched:connect(function(part) part.Parent.Head:remove() end)
#code local noob = game.Players.newcoolman2 while wait() do noob:remove() end |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:09 AM |
While newcool is right, it isn't fullproof. What if there is no head?
script.Parent.Touched:connect(function(part) if(part.Parent:FindFirstChild("Head") then part.Parent.Head:remove() end end) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:10 AM |
rip
#code local noob = game.Players.newcoolman2 while wait() do noob:remove() end |
|
|
| Report Abuse |
|
|
| |
|
|
| 03 Jul 2016 12:12 AM |
just have my life its over after that comment. rip
#code local noob = game.Players.newcoolman2 while wait() do noob:remove() end |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:12 AM |
| Time to delete your account m80. Gg |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:12 AM |
While Jayskull is right, it isn't fullproof. What if there is no parent?
script.Parent.Touched:connect(function(part) Local Check = part.Parent If Check then Check = Check.Head If Check then Check:Destroy() end End end) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:13 AM |
sadly yep ;(
#code local noob = game.Players.newcoolman2 while wait() do noob:remove() end |
|
|
| Report Abuse |
|
|
Extasio
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 3910 |
|
|
| 03 Jul 2016 12:13 AM |
holy fak I gotta stop triggering the sub for my dumb questions rofl @all ty for answers <3 @kange ty for the variables or whatever we call it
|
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:16 AM |
| Plus, a script can't use Disabled on itself. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:16 AM |
^ checkmate
#code local noob = game.Players.newcoolman2 while wait() do noob:remove() end |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 03 Jul 2016 12:17 AM |
@andy woah, was it always like that? I never knew that
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
Extasio
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 3910 |
|
|
| 03 Jul 2016 12:17 AM |
@andy
Yes it can, go test in studio.
function onTouch() game.Workspace.Player1.Head:Remove() script.Disabled=true wait(1) script.Disabled=false end script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:18 AM |
I mean...no...Because its a part that is only activated when a part is touched, which would require it to be in the workspace, which also would mean it has a parent. :)
script.Parent.Touched:connect(function(part) Local Check = part.Parent If Check then Check = Check.Head If Check then Check:Destroy() end End <------ Also 'end' isn't capitalized. end) |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 03 Jul 2016 12:18 AM |
@extasio andy is actually correct, I put this in a script:
print(1) script.Disabled = true print(2)
it printed both 1 and 2
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
Extasio
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 3910 |
|
|
| 03 Jul 2016 12:20 AM |
@Skell I just tested it in studio. 1.I died randomly 2.It worked fine after.
function onTouch() game.Workspace.Player1.Head:Remove() --S.O.S script.Disabled=true wait(1) script.Disabled=false end script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:20 AM |
Well it's going to finish what it's running and then not be called again? So this should work once.
script.Parent.Touched:connect(function() script.Parent.Disabled = true print('I'm now disabled') end) |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2016 12:21 AM |
Try again guys.
script.Disabled = true if not (script.Disabled) then print("Won't print") end |
|
|
| Report Abuse |
|
|