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

Why is my drawing script not working the way I expected it to work?

Asked by 3 years ago
Edited 3 years ago

Alright, so I added a GUI and a frame under the GUI and a script under the frame. My script was this:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local frame = script.Parent
local x
local y

local pressed = false

mouse.Button1Down:Connect(function()
    pressed = true
end)

mouse.Button1Up:Connect(function()
    pressed = false
end)

while wait(0.01) do
    x = mouse.X
    y = mouse.Y
    if pressed == true then
        local dot = Instance.new("ImageLabel")
        dot.Parent = frame
        dot.Name = "Dot"
        dot.BackgroundTransparency = 1
        dot.Image = "http://www.roblox.com/asset/?id=3195888012"
        dot.ImageColor3 = Color3.new(0,0,0)
        dot.Size = UDim2.new(0, 3, 0, 3)
        dot.Position = UDim2.new(0, x, 0, y)
    end
end

I believe that the dot.Position is written out wrong. Anyone out there that knows how to fix it? Try it out yourself.

0
Answering the question in the title: If you give the computer bad instructions you get bad results. Secondly, what isn't working as intended? We don't know what the problem is, post a video of what's happening. radiant_Light203 1166 — 3y
0
Alright. Cyrus_O4 45 — 3y
0
I also simply asked to try it out yourself but ok. Cyrus_O4 45 — 3y
View all comments (2 more)
0
No, you edited that part in later. radiant_Light203 1166 — 3y
0
thats what i mean -_- Cyrus_O4 45 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

Now this was deceptively easy.

Just minus the mouse.X by frame.AbsolutePosition.X and mouse.Y by frame.AbsolutePosition.Y. The problem is that the computer thinks you want the dot to be as far away from the frame's top-right corner as the mouse is away from the screen's top-right corner.

0
tysm Cyrus_O4 45 — 3y
Ad

Answer this question