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

Whats wrong with my script? [closed]

Asked by 9 years ago
if script.Parent.Position == Vector3.new(-74.5, 7.5, 19.5) then
script.Parent.ClickDetector.MouseClick:connect(function()
    game.Workspace.Door.Position = Vector3.new(-80,5.5,25)
    game.Workspace.Door.Rotation = Vector3.new(-180,0,-180)
    script.Parent.Position = Vector3.new(-81.5, 7.5, 23.5)
    script.Parent.Rotation = Vector3.new(0, 90, 0)
elseif script.Parent.Position == Vector3.new(-74.5, 7.5, 19.5) then
script.Parent.ClickDetector.MouseClick:connect(function()
    game.Workspace.Door.Rotation = Vector3.new(0,90,0)
    game.Workspace.Door.Position = Vector3.new(-76, 5.5, 21)
    script.Parent.Position = Vector3.new(-74.5, 8.5, 19.5)
    script.Parent.Rotation = Vector3.new(0, 90, 0)  
end)
end
**If you can tell it is for a door that opens and closes please help**
0
Where is your error? woodengop 1134 — 9y
0
Its just not working, I'm trying to make a door move forwards then backwards by changing its position. This also has the handle changing. If you have a better way of doing it or know how to fix it please tell me. LordZerefu 30 — 9y
0
I'm not a king at Vectors and etc but i think CFrame.new should replace the Vector3. and Try that woodengop 1134 — 9y

Locked by woodengop, Goulstem, and Unclear

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Your problem is that you're trying to make a conditional to activate your event. This won't work, the event will activate reguardless of whether or not the condition returns true or false.

Also, both your conditions are the same.. so the door will always just open

Try putting the conditionals inside the event. And makeing a bool switch to check if the door is open or closed.

local open = false

script.Parent.ClickDetector.MouseClick:connect(function()
    if open then open = false
        workspace.Door.Position = Vector3.new(-80,5.5,25)
        workspace.Door.Rotation = Vector3.new(-180,0,-180)
        script.Parent.Position = Vector3.new(-81.5, 7.5, 23.5)
        script.Parent.Rotation = Vector3.new(0, 90, 0)
    else open = true
        workspace.Door.Rotation = Vector3.new(0,90,0)
        workspace.Door.Position = Vector3.new(-76, 5.5, 21)
        script.Parent.Position = Vector3.new(-74.5, 8.5, 19.5)
        script.Parent.Rotation = Vector3.new(0, 90, 0)  
    end
end)
0
thankyou! LordZerefu 30 — 9y
Ad