Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why are my scripts broken?

Asked by 9 years ago

When the scripts parent is pressed it makes a part invisible this script used to work in the actual play mode but now it only works in roblox studio i don't understand why. be VERY SPECIFIC STEP BY STEP when explaining the problem

Debounce=false
function onClicked()
    if not Debounce then
        Debounce=true

    script.Parent.BrickColor=BrickColor.new("Really red")
    Workspace.invisibleD.Transparency=1
    Workspace.invisibleD.CanCollide=false
    wait(3)
    Workspace.invisibleD.Transparency=0
    Workspace.invisibleD.CanCollide=true
    wait(5)
    script.Parent.BrickColor=BrickColor.new("Lime green")
    Debounce=false
end

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

This is another script when a gui button is clicked its suppose to open a frame

script.Parent.MouseButton1Click:connect(function()
    script.Parent.Parent.Frame.Visible=true
    script.Parent.Parent.Frame.VoteText.Visible=true
    script.Parent.Parent.Frame.CloseButton.Visible=true

end)

2 answers

Log in to vote
-1
Answered by
Nymint 85
9 years ago

Probably the pathfinding common problem, please consider looking through old questions before posting.

Possible solution

You can't just use script.Parent.Parent.Parent.Parent to do certain things, the possibilities of your script to break could increase.

You really never know whenever one of these "Parent.Parent.Parent.Parent..." doesn't exist yet or just doesn't exist.

This is why Part:WaitForChild("Noob") and Part:FindFirstChild("AnotherNoob") are useful.

0
i dont really get how to use Part:WaitForChild() or Part:FindFirstCHild to fit into my script giving me an example would be nice. threatboy101 2 — 9y
0
Sure, WaitForChild waits for a children with a specific name, because you never know if the script you just made will run before the objects appear, so it waits for them first, pausing the current thread, if it already exists then it will instantly recognize it. FindFirstChild FINDS a child with a specific name instantly, if it doesn't exist it will return nil so you can use if Part:FindFirstChil Nymint 85 — 9y
0
if Part:FindFirstChild("lol") then or if Part:FindFirstChild("lol")==nil then Nymint 85 — 9y
Ad
Log in to vote
0
Answered by
Adryin 120
9 years ago

I agree with 6Pen, maybe the object is nil, meaning the Frame doesnt exist, like you added too many or too much parents. So try doing something like this incase the script breaks:

 function onClicked()
    if not Debounce then
        Debounce=true
    script.Parent.BrickColor=BrickColor.new("Really red")
    Workspace.invisibleD.Transparency=1
    Workspace.invisibleD.CanCollide=false
    wait(3)
    Workspace.invisibleD.Transparency=0
    Workspace.invisibleD.CanCollide=true
    wait(5)
    script.Parent.BrickColor=BrickColor.new("Lime green")
    Debounce=false
end
script.Parent.MouseButton1Click:connect(function()
if script.Parent.Parent:findFirstChild("Frame") then
    onClicked()
end
end)




0
this used to work and all the sudden it doesnt and the frame has to exist threatboy101 2 — 9y
0
Maybe you changed the frame's parent perhaps? Adryin 120 — 9y

Answer this question