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 » Scripting Helpers
Home Search
 

Re: .TouchEnded script won't work

Previous Thread :: Next Thread 
tuxedoman23 is not online. tuxedoman23
Joined: 24 Apr 2009
Total Posts: 4670
05 May 2013 10:22 PM
local db = true
local car = script.Parent.Parent

script.Parent.TouchEnded:connect(function(hit)
local p = hit.Parent:findFirstChild("Humanoid")
local checkplayer = hit.Parent
if db then
db = false
if p then
if car:findFirstChild(checkplayer) then
hit.Parent.Parent = Workspace
print("This is not "..hit.Parent.Name.."'s car!")
wait(1)
end
end
db = true
end
end)



I made this script to set the player's parent to the Workspace when he/she jumps out of a vehicle seat. However, nothing happened when I went to test it. Help?
Report Abuse
tuxedoman23 is not online. tuxedoman23
Joined: 24 Apr 2009
Total Posts: 4670
06 May 2013 09:58 PM
Bump
Report Abuse
KillerKyle is not online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
06 May 2013 10:34 PM
You're doing all this for a vehicle seat? When you enter a vehicle seat, a "Weld" is added. Instead of touch, why not use "ChildAdded" and "ChildRemoved"?

EX:

--Put this script into your vehicle seat

Seat = script.Parent

Seat.ChildAdded:connect(function(child)
if child.ClassName == "Weld" then
print ("A weld as been added. Someone is sitting in the seat")
print (""..child.Part1.Parent.Name.." is sitting in the seat")
end
end)

Seat.ChildRemoved:connect(function(child)
if child.ClassName == "Weld" then
print ("A weld has been removed from the seat")
print ("The seat is now available")
end
end)

--I think this will work. Not tested.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
06 May 2013 10:41 PM
Just a little addition that may make it simpler or easier to understand. Credit to Kyle.

Seat = script.Parent

function Seated(char)
print(char.Name..' has sat down.');
end

function UnSeated(char)
print(char.Name..' has got up.');
end

Seat.ChildAdded:connect(function(child)
if child.ClassName == "Weld" then
Seated(child.Part1.Parent);
end
end)

Seat.ChildRemoved:connect(function(child)
if child.ClassName == "Weld" then
UnSeated(child.Part1.Parent);
end
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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