Hi, I am trying to script a bowling ball return which has an automatic load up for the next ball - I am just wondering how to script the ball return button which tells the customer if the ball return is broken (if the ball is not appearing on the Workspace).
This script which I would be thinking that would work, when the ball is visible but what if it doesn't?
if script.Parent.Parent.Ball2 then script.Parent.SurfaceGui.TextLabel.Text = "Out of use! end
If you want more explanation, please comment below!
Thanks!
You want to use FindFirstChild()
to do this,
FindFirstChild basically does what it's name says, it will find the child of something(You use the Argument to tell what it's looking for)
This is what your code should look like -
if game.Workspace.FindFirstChild("Ball2") then script.Parent.SurfaceGui.TextLabel.Text = "Out of use!" end
If you didn't notice, you did not fully quotation your Out of Use string. I did this for you, do not forget to use close quotation marks!
Hi, Thanks for getting back to me. I have got the full script here which I have added your code into it - the main bit of the script like "Please wait.." works fine, but I have tested this when there is no ball on the Workspace and there is a problem which is that the light of the button has not been changed and the text has not changed either. So, I am just wondering if I might've put in the wrong place or do you think I have added something extra which it wont work.
Anyways, here is the full code.
function onClicked() script.Parent.ClickDetector.MaxActivationDistance = 0 script.Parent.BrickColor = BrickColor.new (21) m = script.Parent.Parent.Ball1:Clone() m.Parent = game.Workspace m.Handle.CanCollide = true m.Handle.Anchored = false m.Handle.Transparency = 0 m.Enabled = true script.Parent.SurfaceGui.TextLabel.Text = "Please wait." -- This works fine! wait(1) script.Parent.SurfaceGui.TextLabel.Text = "Please wait.." -- This works fine! wait(1) script.Parent.SurfaceGui.TextLabel.Text = "Please wait..." -- This works fine! wait(1) script.Parent.SurfaceGui.TextLabel.Text = "Please wait." -- This works fine! wait(1) script.Parent.SurfaceGui.TextLabel.Text = "Please wait.." -- This works fine! wait(1) script.Parent.SurfaceGui.TextLabel.Text = "Please wait..." -- This works fine! wait(1) script.Parent.SurfaceGui.TextLabel.Text = "Please wait." -- This works fine! wait(1) script.Parent.SurfaceGui.TextLabel.Text = "Please wait.." -- This works fine! wait(1) script.Parent.SurfaceGui.TextLabel.Text= "Regen Ball" -- This works fine! script.Parent.ClickDetector.MaxActivationDistance = 30 script.Parent.BrickColor = BrickColor.new (28) if game.Workspace.FindFirstChild("Ball1") then -- This doesn't work, unless if I have put it in the wrong place of the script. script.Parent.SurfaceGui.TextLabel.Text = "Out of use!" script.Parent.BrickColor = BrickColor.new (21) -- I have added this a bit extra including this 3 lined code! end end script.Parent.ClickDetector.MouseClick:connect(onClicked)