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: Button help

Previous Thread :: Next Thread 
iixono is not online. iixono
Joined: 03 Jan 2016
Total Posts: 123
24 Aug 2017 05:56 AM
So what I want to do is have a button that loads in a model, and if that model is loaded in, the button doesn't work, but if the model isn't in-game, it works again, so I added a script in the model that destroys it after 20 seconds. So if the item was spawned in the button doesn't work, but then if it's despawned (removed from workspace) the button works again, this is the script I had but it doesn't work.

if game.Workspace.Car1 then
script.Parent.MaxActivationDistance = 0
else
script.Parent.MaxActivationDistance = 32
end

Anybody able to hand me a working script? If they want to that is.
Report Abuse
iiGaIaxyWolf is online. iiGaIaxyWolf
Joined: 16 May 2013
Total Posts: 47
24 Aug 2017 06:03 AM
while true do
wait(5)
if game.Workspace:WaitForChild('Car1') then
script.Parent.MaxActivationDistance = 0
else
script.Parent.MaxActivationDistance = 32
end
Report Abuse
iixono is not online. iixono
Joined: 03 Jan 2016
Total Posts: 123
24 Aug 2017 06:33 AM
hmm doesn't seem to work,

Workspace.Regen1.ClickDetector.Script:7: 'end' expected (to close 'while' at line 1) near

is the error I get.
Report Abuse
iixono is not online. iixono
Joined: 03 Jan 2016
Total Posts: 123
24 Aug 2017 06:39 AM
Okay I fixed that error but now I need it to be able to go back to MaxActivationDistance if the car is despawned, how'd I do that?
Report Abuse
iiGaIaxyWolf is online. iiGaIaxyWolf
Joined: 16 May 2013
Total Posts: 47
24 Aug 2017 06:45 AM
try

while true do
wait(5)
if game.Workspace:FindFirstChild('Car1') then
script.Parent.MaxActivationDistance = 0
elseif not game.Workspace:FindFirstChild('Car1')
script.Parent.MaxActivationDistance = 32
end
end
Report Abuse
iixono is not online. iixono
Joined: 03 Jan 2016
Total Posts: 123
25 Aug 2017 01:43 AM
Thanks, that worked!
Report Abuse
Reapqr is not online. Reapqr
Joined: 27 Jan 2017
Total Posts: 921
25 Aug 2017 01:45 AM
Can you help me on my fourm post?
Report Abuse
igrach2 is not online. igrach2
Joined: 09 Mar 2017
Total Posts: 252
25 Aug 2017 04:12 AM
local sp=script.Parent
local function a()
local c;c=workspace.ChildAdded:Connect(function(v)wait(1)
if v.Name
=="Car1"then
c:Disconnect()sp.MaxActivationDistance=0
local b
b=v.Changed:Connect(function(p)
if p=="Parent"and not v.Parent then
b:Disconnect()sp.MaxActivationDistance=32
a()
end
end)
end
end)end;a()
sp.MaxActivationDistance=32
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