Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I fix this annoying bug? (lookvector and cframe)

local p = game.Players.LocalPlayer
local m = p:GetMouse()

m.Button1Down:Connect(function()
    local p = Instance.new("Part")
    p.CFrame = CFrame.new(game.Players.LocalPlayer.Character.Head.CFrame * m.Hit.LookVector*2)
    p.Parent = workspace
end)

I want a part to spawn 2 studs away from the direction the player is clicking. For example, if I click anywhere infront of me, it will spawn 2 studs infront of me. And does that with all angels around me.

This script works for a bit, but then it breaks, why?

1 answer

You should try mouseclick

local p = game.Players.LocalPlayer
local m = p:GetMouse()

m.MouseClick:Connect(function()
    local p = Instance.new("Part")
    p.CFrame = CFrame.new(game.Players.LocalPlayer.Character.Head.CFrame * m.Hit.LookVector*2)
    p.Parent = workspace
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.