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

Frames dosent add in right position?

Asked by 3 years ago

I am trying to make a game were you add frames on click so once you click there will pop out a frame but once i click they intstence in diffrent position were i clicked

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.Y / 1000 ,0, mouse.X / 1000 ,0)
dot.Size = UDim2.new(0, 10, 0, 10) 
dot.Parent = game.StarterGui.ScreenGui.Frame
end)

1 answer

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

Before I try to answer I want to say I am on my phone so sorry if this is spelt weird or you see any spelling errors

The main issue I see right away is you’re using a very weird position for the gui object

Try:

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, 10, 0, 10) 
dot.Parent = game.StarterGui.ScreenGui.Frame
end)

0
This will get your screen size no matter the size and should place it in the right position, I also forgot to mention in the udim2 you had your X and Y mixed up I_Nev 200 — 3y
0
it shows me this error ViewportSizeX is not a valid member of Camera kristupas12344 26 — 3y
0
@kristupas12344 change it to ViewportSize.X Leamir 3138 — 3y
0
My bad, was a mistake, i'll edit it to the correct thing I_Nev 200 — 3y
Ad

Answer this question