generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: (Beginner)How to make it so it's the person who steps on it?

Previous Thread :: Next Thread 
Extasio is not online. 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 is not online. Extasio
Joined: 16 Oct 2011
Total Posts: 3910
03 Jul 2016 12:00 AM
bump
Report Abuse
Skellobit is not online. 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
kangerujack is not online. kangerujack
Joined: 08 Nov 2009
Total Posts: 690
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 is not online. 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 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
03 Jul 2016 12:03 AM
Heh nvm.
Report Abuse
kangerujack is not online. kangerujack
Joined: 08 Nov 2009
Total Posts: 690
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
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
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
Jayskull900 is not online. Jayskull900
Joined: 26 Nov 2006
Total Posts: 590
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
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
03 Jul 2016 12:10 AM
rip


#code local noob = game.Players.newcoolman2 while wait() do noob:remove() end
Report Abuse
kangerujack is not online. kangerujack
Joined: 08 Nov 2009
Total Posts: 690
03 Jul 2016 12:10 AM
^rekt omg lelz
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
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
kangerujack is not online. kangerujack
Joined: 08 Nov 2009
Total Posts: 690
03 Jul 2016 12:12 AM
Time to delete your account m80. Gg
Report Abuse
Andyliu5000 is not online. Andyliu5000
Joined: 02 Nov 2013
Total Posts: 969
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
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
03 Jul 2016 12:13 AM
sadly yep ;(


#code local noob = game.Players.newcoolman2 while wait() do noob:remove() end
Report Abuse
Extasio is not online. 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
Andyliu5000 is not online. Andyliu5000
Joined: 02 Nov 2013
Total Posts: 969
03 Jul 2016 12:16 AM
Plus, a script can't use Disabled on itself.
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
03 Jul 2016 12:16 AM
^ checkmate


#code local noob = game.Players.newcoolman2 while wait() do noob:remove() end
Report Abuse
Skellobit is not online. 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 is not online. 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
Jayskull900 is not online. Jayskull900
Joined: 26 Nov 2006
Total Posts: 590
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 is not online. 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 is not online. 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
kangerujack is not online. kangerujack
Joined: 08 Nov 2009
Total Posts: 690
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
Jayskull900 is not online. Jayskull900
Joined: 26 Nov 2006
Total Posts: 590
03 Jul 2016 12:21 AM
Try again guys.


script.Disabled = true
if not (script.Disabled) then
print("Won't print")
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image