Hi, I'm currently making a editor for my game in Roblox, and when you click it's meant to place a object, but it doesn't do that. This is the code, if you can fix it in some way, that would be seriously helpful.
local UserInputService = game:GetService('UserInputService') UserInputService.InputBegan:connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then local Mouse = game.Players.LocalPlayer:GetMouse() local CloneHitCircle = script.Parent.PlaceHitCircle:Clone() print("Mouse clicked, clone added.") CloneHitCircle.Image = 'rbxgameasset://Images/Hit_Circle' CloneHitCircle.Parent = script.Parent CloneHitCircle.Name = "HitCircle" CloneHitCircle.Position = UDim2.new(Mouse.X, Mouse.Y) end end)
Hey just a heads-up, that should definitely error, if it isn't erroring then your code isn't running, anyways here's the script.
local UserInputService = game:GetService('UserInputService') local Mouse = game.Players.LocalPlayer:GetMouse() -- define it outside of event. UserInputService.InputBegan:connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then local CloneHitCircle = script.Parent.PlaceHitCircle:Clone() print("Mouse clicked, clone added.") CloneHitCircle.Image = 'rbxgameasset://Images/Hit_Circle' CloneHitCircle.Parent = script.Parent CloneHitCircle.Name = "HitCircle" CloneHitCircle.Position = UDim2.new(Mouse.Hit.X, Mouse.Hit.Y) -- Mouse.Hit, not Mouse end end)