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

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

Asked by 5 years ago

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

0
Post the hierarchy. User#19524 175 — 5y
0
The script must be inside of the parts which are inside of the model . based on your screenshot User#17685 0 — 5y

2 answers

Log in to vote
1
Answered by
Delude_d 112
5 years ago
Edited 5 years ago
-- 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.
0
huh?? Delude_d 112 — 5y
0
You’re saying the ClickDetector is being called too early. What?? User#19524 175 — 5y
0
It is, before it can load in either that or the object doesn't exist. Delude_d 112 — 5y
0
"Before it can load" so I have to use game:WaitForChild("Players") or wait(500000000) game:GetService("Players") ? User#19524 175 — 5y
View all comments (4 more)
0
Not my point. Delude_d 112 — 5y
0
It's not misinformation, It's what he learnt. Aren't we all trying to help? , Please be kind. User#17685 0 — 5y
0
I'll upvote this. I don't see why this is misinformation. brokenVectors 525 — 5y
0
Did he just removed his qwerty comment? hmmmm? lmao User#17685 0 — 5y
Ad
Log in to vote
-1
Answered by 5 years ago

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")



0
Error. User#19524 175 — 5y
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) RobotChitti 167 — 5y
0
Thanks, bud. I did something like that before, hmmmmm but anyway , Thanks , lmao User#17685 0 — 5y

Answer this question