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: How to make this script work for all players

Previous Thread :: Next Thread 
mystic48 is not online. mystic48
Joined: 02 Apr 2009
Total Posts: 1439
20 Jul 2012 02:24 PM
I have a button with this script in:

function onClicked()
p = game.Players:GetChildren()
for i = 1, #p do
p[i].Character.Car.VehicleSeat.MaxSpeed = 0
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)



As you can see, it forces a car to stop (changing speed). It only works if I'm in the car, not when others are in. the car. Any help would be appreciated, thank you!
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
20 Jul 2012 02:28 PM
Are you sure the car is a child of the other players when they sit in it?
Report Abuse
abx1 is not online. abx1
Joined: 13 Nov 2008
Total Posts: 4979
20 Jul 2012 02:29 PM
@MrChubbs

VehicleSeat's do that.
Report Abuse
mystic48 is not online. mystic48
Joined: 02 Apr 2009
Total Posts: 1439
20 Jul 2012 02:34 PM
Double checked the models, directory etc.

The weird thing is, now its not working for myself either unlike a few minutes ago.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
20 Jul 2012 02:37 PM
No they do not, the car remains in workspace unless you put a script to change its parent.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
20 Jul 2012 02:37 PM
Whats the output when it doesn't work?
Report Abuse
abx1 is not online. abx1
Joined: 13 Nov 2008
Total Posts: 4979
20 Jul 2012 02:37 PM
function onClicked()
p = game.Players:GetChildren()
for i = 1, #p do
if p[i]:findFirstChild("Car") ~= nil then
p[i].Character.Car.VehicleSeat.MaxSpeed = 0
end
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
20 Jul 2012 02:40 PM
function onClicked()
p = game.Players:GetChildren()
for i = 1, #p do
if p[i]:findFirstChild("Car") then
p[i].Character.Car.VehicleSeat.Torque = 0
end
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
20 Jul 2012 02:41 PM
This one is slightly better because now it can't turn.
Report Abuse
mystic48 is not online. mystic48
Joined: 02 Apr 2009
Total Posts: 1439
20 Jul 2012 03:11 PM
No output detected and the new scripts (neither of them) are functional, sadly.
Report Abuse
mystic48 is not online. mystic48
Joined: 02 Apr 2009
Total Posts: 1439
20 Jul 2012 03:12 PM
"Not functional, sorry!"
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
20 Jul 2012 03:19 PM
function onClicked()
p = game.Players:GetChildren()
for i = 1, #p do
if p[i]:findFirstChild("Car") then
print("Car Found")
else
print("No Car")
end
if workspace:findFirstChild("Car") then
print("Car is in workspace")
end
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
mystic48 is not online. mystic48
Joined: 02 Apr 2009
Total Posts: 1439
20 Jul 2012 03:30 PM
The car is in the workspace, now I know this may be a stupid question but how can I adjust the code to work for the workspace now while ensuring the code still works for all players?
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
20 Jul 2012 03:57 PM
function onClicked()
p = game.Players:GetChildren()
workspace.Car.VehicleSeat.MaxSpeed = 0 -- assuming there is only one car.
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
20 Jul 2012 03:58 PM
Woops, get rid of the p = line.
Report Abuse
mystic48 is not online. mystic48
Joined: 02 Apr 2009
Total Posts: 1439
20 Jul 2012 04:01 PM
and if there are multiple ones with the same name for multiple players?
Report Abuse
guest55255 is not online. guest55255
Joined: 06 Jun 2010
Total Posts: 708
20 Jul 2012 05:02 PM
The problem is that you have no redundancy if there is no car in the player, the script will break.

The future is on the Horizone...

S-1894>()
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