Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

6 comments

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.

0

Alright.

0

I also simply asked to try it out yourself but ok.

0

No, you edited that part in later.

0

thats what i mean -_-

1 answer

✓ Accepted answer

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.

1 comment

0

tysm

This discussion is preserved as it was. New answers, comments, and votes are closed.