I'm trying to make that if you click R it creates a part. I have no errors and it creates a part but it doesn't position it right. When I click R when my mouse is in another direction it makes the position different but it doesn't work like always :P
Local Script (Inside StarterGui):
local UIS = game:GetService("UserInputService")
local target = game.Players.LocalPlayer:GetMouse().Hit
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.R then
local Part = Instance.new("Part", workspace)
Part.Size = Vector3.new(4, 1, 2)
Part.Anchored = true
local x = target.X
local y = target.Y
local z = target.Z
Part.Position = Vector3.new(x, y, z)
end
end
UIS.InputBegan:Connect(onKeyPress)
I would really appreciate it if you will help me with my problem, Plus I'll accept your answer if it worked.
Thanks, MajinBluee

2 comments
Thanks bruv.
np <3