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

Create a circle where is the mouse when i click on the button?

Asked by 5 years ago

Hey devs! I want create than when the client click on a button, a circle spawn where is the mouse here. But i'm blocked, the circle position is hard to find. Can anyone help me?

--< Services
local PlayerService = game:GetService('Players')
local RStorageService = game:GetService('ReplicatedStorage')
local UserInputService = game:GetService('UserInputService')

--< Variables
local Player = PlayerService.LocalPlayer
local Mouse = Player:GetMouse()

local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')
local TextButton = ScreenGui:WaitForChild('TextButton')
local Template = TextButton:WaitForChild('Template')

--< Events
TextButton.MouseButton1Click:Connect(function()
    local newCircle = Template:Clone()
    newCircle.Parent = TextButton
    newCircle.Visible = true

    newCircle.Position = UDim2.new(0.001 * Mouse.Y, 0, 0.001 * Mouse.X, 0)
    print(newCircle.Position, Mouse.Y, Mouse.X)
end)

Sorry for my english I speak originally french.

0
Why are you dividing the mouse X and mouse Y by 1000? programmerHere 371 — 5y

Answer this question