Help with mouse position

Hey so I’m trying to get the position of my player’s mouse on their screen so when a player clicks, a GUI clones then goes to that position to show before then disappearing a few moments later. However, after looking at some devforum posts about mouse position and google and youtube, I cannot find out a solution so here is the script. The section where I have put “mp.Position = Mouse.Position” is a filler because I don’t know what to put there for now and I know that’s definitley not how you get a mouse position!

LocalScript
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local cooldown = false

script.Parent.Activated:Connect(function()
	local cooldowntime = script.Parent.Cooldown.Value

	if cooldown == false and Player.Storage.Value < Player.StorageCapacity.Value then
		cooldown = true

		local success, result = pcall(function()
			game.ReplicatedStorage.Remotes.LokiaBrick:FireServer(game.Players.LocalPlayer)
					
			local mp = game.ReplicatedStorage.ClickLabel:Clone()
			mp.Parent = Player.PlayerGui.Clickers
			mp.Position = Mouse.Position

			game:GetService("TweenService"):Create(mp, TweenInfo.new(.5), {ImageTransparency = 0}):Play()
			wait(.7)
			game:GetService("TweenService"):Create(mp, TweenInfo.new(.5), {ImageTransparency = 1}):Play()
			wait(.5)

			mp:Destroy()
		end)

		if not success then
			warn("Error: " .. result)
		end

		script.Parent.Enabled = false
		wait(cooldowntime)
		script.Parent.Enabled = true
		cooldown = false
	end
end)

mp.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.