Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script Fixed, but Doesn't Function Like I want it To Do?

This script was fixed by Zafirua and surprisingly it didn't work. This time I added the Output, along with the picture of the studio of what I have on my Workspace, and the script fixed by Zafirua, which I want to say thank you so much!

https://imgur.com/CejNXXc

-- [Declaration Section]
local Up               = script.Parent.Up;
local Down             = script.Parent.Down;
local Left             = script.Parent.Left;
local Right            = script.Parent.Right;

--\\ Variables 
local UpOn             = false;
local DownOn           = false;
local LeftOn           = false;
local RightOn          = false;

-- [Processing Section]
local function On_Clicked ()
    if not UpOn then 
        UpOn = true;

        Up.CFrame = Up.CFrame + Vector3.new(0, -0.09 ,0);
        wait()
        Up.CFrame = Up.CFrame + Vector3.new(0, 0.09 ,0);

        UpOn = false;
    elseif not DownOn then
        DownOn = true;

        Down.CFrame = Down.CFrame + Vector3.new(0, -0.09 ,0);
        wait()
        Down.CFrame = Down.CFrame + Vector3.new(0, 0.09 ,0);

        DownOn = false;
    elseif not LeftOn then 
        LeftOn = true;

        Left.CFrame = Left.CFrame + Vector3.new(0, -0.09 ,0);
        wait()
        Left.CFrame = Left.CFrame + Vector3.new(0, 0.09 ,0);

        LeftOn = false;
    elseif not RightOn then 
        RightOn = true;

        Right.CFrame = Right.CFrame + Vector3.new(0, -0.09 ,0);
        wait()
        Right.CFrame = Right.CFrame + Vector3.new(0, 0.09 ,0);

        RightOn = false;
    else 
        return;
    end;
end;

-- [Connecting Section]
script.Parent.ClickDetector.MouseClick:Connect(On_Clicked);

Output 22:39:58.389 - ClickDetector is not a valid member of Model 22:39:58.392 - Stack Begin 22:39:58.393 - Script 'Workspace.RemoteControl.Script', Line 53 22:39:58.393 - Stack End

2 comments

0

Post the hierarchy.

0

The script must be inside of the parts which are inside of the model . based on your screenshot

2 answers

-- Try script.Parent:WaitForChild("ClickDetector").MouseClick:Connect(On_Clicked);
-- If it errors, or not work. It means, clickdetector is being called too early. Try fixing it using a wait, find, or any other useful ones.

8 comments

0

huh??

0

You’re saying the ClickDetector is being called too early. What??

0

It is, before it can load in either that or the object doesn't exist.

0

"Before it can load" so I have to use game:WaitForChild("Players") or wait(500000000) game:GetService("Players") ?

0

Not my point.

0

It's not misinformation, It's what he learnt. Aren't we all trying to help? , Please be kind.

0

I'll upvote this. I don't see why this is misinformation.

0

Did he just removed his qwerty comment? hmmmm? lmao

Should you try?

-- [Declaration Section]
local Up               = script.Parent.Up;
local Down             = script.Parent.Down;
local Left             = script.Parent.Left;
local Right            = script.Parent.Right;

--\\ Variables 
local UpOn             = false;
local DownOn           = false;
local LeftOn           = false;
local RightOn          = false;

-- [Processing Section]
local function On_Clicked (which)
  if which == "Up" then 
    UpOn = true;

    Up.CFrame = Up.CFrame + Vector3.new(0, -0.09 ,0);
    wait()
    Up.CFrame = Up.CFrame + Vector3.new(0, 0.09 ,0);

    UpOn = false;
  elseif which == "Down" then
    DownOn = true;

    Down.CFrame = Down.CFrame + Vector3.new(0, -0.09 ,0);
    wait()
    Down.CFrame = Down.CFrame + Vector3.new(0, 0.09 ,0);

    DownOn = false;
  elseif which == "Left" then 
    LeftOn = true;

    Left.CFrame = Left.CFrame + Vector3.new(0, -0.09 ,0);
    wait()
    Left.CFrame = Left.CFrame + Vector3.new(0, 0.09 ,0);

    LeftOn = false;
  elseif which == "Right" then 
    RightOn = true;

    Right.CFrame = Right.CFrame + Vector3.new(0, -0.09 ,0);
    wait()
    Right.CFrame = Right.CFrame + Vector3.new(0, 0.09 ,0);

    RightOn = false;
  else 
    return;
  end;
end;

-- [Connecting Section]
Up.ClickDetector.MouseClick:Connect(On_Clicked("Up")
  Down.ClickDetector.MouseClick:Connect(On_Clicked("Down")
    Left.ClickDetector.MouseClick:Connect(On_Clicked("Left")
      Right.ClickDetector.MouseClick:Connect(On_Clicked("Right")



3 comments

0

Error.

0

That doesn't work. The first error mentioned was to put the ')' after line 53 which I did. But it didn't function as it was supposed to do. This is the output: 13:15:27.358 - Attempt to connect failed: Passed value is not a function 13:15:27.360 - Stack Begin 13:15:27.362 - Script 'Workspace.RemoteControl.Control', Line 56 13:15:27.362 - Stack End 13:15:41.055 - attempt to call a nil value (x3)

0

Thanks, bud. I did something like that before, hmmmmm but anyway , Thanks , lmao

This discussion is preserved as it was. New answers, comments, and votes are closed.