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

Why my frame position isnt accurite?

Asked by 3 years ago

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

Log in to vote
0
Answered by
I_Nev 200 Moderation Voter
3 years ago

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)
0
Use scale instead of offset. nekosiwifi 398 — 3y
0
Or use use offset since hes wanting it set based off pixles, lol I_Nev 200 — 3y
Ad

Answer this question