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

Why didn't it position after I onClicked it?

Asked by 9 years ago

I hit the lid, and it didn't like put it in the position I wanted it to be. This is what the script is:

local lid = game.Workspace.BoxCD.Lid
sound = Instance.new("Sound")

function onClicked()
    if onClicked(lid) then
        lid.CFrame = CFrame.new(9.445, lid.CFrame.Y, lid.CFrame.Z)
        wait(0.1)
        lid.CFrame = CFrame.new(8.205, lid.CFrame.Y, lid.CFrame.Z)
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
3
You're expecting a function call to return a true or false value to a if then statement that does not return one. Is this script parented to 'lid'? M39a9am3R 3210 — 9y
0
Oh okay. Thanks M39 RobotChitti 167 — 9y

1 answer

Log in to vote
1
Answered by
Validark 1580 Snack Break Moderation Voter
9 years ago

Sorry if I didn't understand the script. You stated the problem, but you didn't say what you intended the script to do.

In my script, when you click script.Parent.ClickDetector, it makes the lid switch between the two positions of Cframe.X = 8.205 and Cframe.X = 9.445.

local lid = game.Workspace.BoxCD.Lid
local sound = Instance.new("Sound")
local jammed = false
function onClicked() --fires each time the button is clicked
    if not jammed then
    jammed = true
        lid.CFrame = CFrame.new( ((lid.CFrame.X == 8.205) and 9.445 or 8.205), lid.CFrame.Y, lid.CFrame.Z)
        wait(0.1)
        jammed = false
    end
end

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

Ad

Answer this question