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

Why my frame position isnt accurite?

i am trying to make a game were you click and at that position instences new frame but once i click frame instences bellow the cursor or higher

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()


mouse.Button1Down:Connect(function()
local dot = Instance.new("Frame")
dot.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
dot.Position = UDim2.new(mouse.X/game.workspace.CurrentCamera.ViewportSize.X,0, mouse.Y/game.workspace.CurrentCamera.ViewportSize.Y,0)
	dot.Size = UDim2.new(0, 20, 0, 20)
	dot.BorderSizePixel = 0
dot.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame
end)

1 answer

✓ Accepted answer

Now i am on my computer and can test this myself, here is a working version

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()


mouse.Button1Down:Connect(function()
local dot = Instance.new("Frame")
dot.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
dot.Position = UDim2.new(0,mouse.X,0, mouse.Y)
    dot.Size = UDim2.new(0, 20, 0, 20)
    dot.BorderSizePixel = 0
dot.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame
end)

2 comments

0

Use scale instead of offset.

0

Or use use offset since hes wanting it set based off pixles, lol

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