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

Any help with this script? I got confused

Asked by 10 years ago

Hi,

I have this script and I want it so that I press the button and it will go up. But when I press it again I want it to go back down to its original position. Here is the script, I have copied it from the other buttons that I have used but I got confused with all the coordinates and stuff.

Script:

btn = script.Parent.ClickDetector

function onClick()
    if script.Parent.Parent.StageScreen.SurfaceGui.Enabled == false and
       script.Parent.Parent.StageScreen.Position == "-103.5, 23.99, 243.1" then -- They are the origin position.
        script.Parent.Parent.StageScreen.SurfaceGui.Enabled = true
        script.Parent.BrickColor = BrickColor.new("Medium stone grey") -- Not sure if s.p is the part, just change if needed
    else
        script.Parent.Parent.SR.CanCollide = false
        script.Parent.BrickColor = BrickColor.new("Really red") -- Same here
    end
end

btn.MouseClick:connect(onClick)

I want it so that the part would move from; Starting: -103.5, 23.99, 243.1 End: -103.5, 35.99, 243.1 And then move back when I press the button again.

I would also like it to turn off the surface gui. The link to it is: script.Parent.Parent.StageScreen.SurfaceGui.Enabled

Thank you Kieranm9090

If you need more info just pm me, Thanks!

2 answers

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

Many things that use three dimensions in Roblox are what's called Vector3 values (i.e. Position, Velocity). In order to check these values, we don't surround the values with quotes, but rather do this.

script.Parent.Parent.StageScreen.Position == "-103.5, 23.99, 243.1" then

Should be

script.Parent.Parent.StageScreen.Position == Vector3.new(-103.5, 23.99, 243.1) then
0
Ok thanks! I will see if I can get it fitted into the script now! kieranm9090 49 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

I got this but it only turns off the screen. It does not move it! :O

btn = script.Parent.ClickDetector

function onClick()
    if script.Parent.Parent.StageScreen.SurfaceGui.Enabled == false and
       script.Parent.Parent.StageScreen.Position == Vector3.new(-103.5, 35.99, 243.1) then
       script.Parent.Parent.StageScreen.SurfaceGui.Enabled = true
       script.Parent.Parent.StageScreen.Position = Vector3.new( -103.5, 23.99, 243.1)
        script.Parent.BrickColor = BrickColor.new("Medium stone grey") -- Not sure if s.p is the part, just change if needed
    else
        script.Parent.BrickColor = BrickColor.new("Really red") -- Same here
        script.Parent.Parent.StageScreen.SurfaceGui.Enabled = false and
        script.Parent.Parent.StageScreen.Position == Vector3.new(-103.5, 35.99, 243.1)
    end
end

btn.MouseClick:connect(onClick)

Answer this question