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

How to make an if absolute position then?

Asked by 4 years ago
Edited 4 years ago

Before you read my question, please be aware that I'm new to scripting so try to explain it in a simple way so I can understand. So basically what I want to know is how to use the Absolute Position as an if so if the Absolute Position is something specific like 80, 800 then a function is triggered. The problem is the comma because it breaks the script. I'll put the entire Local Script below.

local Player = game.Players.LocalPlayer
local GB = script.Parent
local GF = script.Parent.Parent["Gift Frame"]

GB.MouseButton1Click:Connect(function()
    if GF.AbsolutePosition == 80, 800 then
    GF:TweenPosition(UDim2.new(0, 80, 0, 15), "Out", "Bounce")
    else
    GF:TweenPosition(UDim2.new(0, 80, 0, 800), "Out", "Bounce")
    end
end)
0
This is because you’re dealing with a malformed comparison conditional. If you wish to match data, you have to do so within the same datatype. Since AbsolutePosition is a UDim2, you need to write: If (Gui.AbsolutePosition == UDim2.new(0,0,0,0)) then Ziffixture 6913 — 4y
0
Oh, thank you very much. As I said I just started scripting so I don't know exactly how everything works, this helped a lot. DukeOfWorms 18 — 4y

1 answer

Log in to vote
0
Answered by
ScuffedAI 435 Moderation Voter
4 years ago
Edited 4 years ago

Since the property AbsolutePosition is a Vector2 object, all you would have to do is to turn your values into Vector2 object. Here's how line 6 would now look instead:

if GF.AbsolutePosition == Vector2.new(80, 800) then
0
Haha I read the code wrong, me stupid. :P LinavolicaDev 570 — 4y
0
It worked perfectly, I didn't knew it was so easy to solve. Thank you very much. DukeOfWorms 18 — 4y
0
be sure to accept this answer if it helped you out. ScuffedAI 435 — 4y
Ad

Answer this question