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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 03 Jan 2016 |
| Total Posts: 123 |
|
| |
|
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
|
  |
| 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 |
|
|