#Trying to spawn a part depending on the player's orientatiob

8 messages · Page 1 of 1 (latest)

granite yoke
#
createPartInFrontOfCamera()
        local cameraPosition = getCameraPosition()
        local cameraOrientation = getCameraOrientation()
        
        
        if cameraPosition and cameraOrientation then
            local PX = PXCal(cameraPosition,cameraOrientation)
            local PZ = PZCal(cameraPosition,cameraOrientation)

            
            local partPosition = Vector3.new(cameraPosition.X * PX, 2.5, cameraPosition.Z * PZ)
            local partOrientation = Vector3.new(cameraOrientation.X,0,cameraOrientation.Z)
            local part = Instance.new("Part")
            part.Size = Vector3.new(10, 5, 1)
            part.Position = partPosition
            part.Orientation = partOrientation
            part.Anchored = true
            part.CanCollide = true
            part.Name = "stickwall"
            part.Color = Color3.new(0.427451, 0.243137, 0.0588235)
            part.Parent = game.Workspace
        end
    end
    if workspace:FindFirstChild("stickwall") then
        workspace.stickwall:Destroy()
    end
    createPartInFrontOfCamera()
end)
#

so, theres the function called: PXCal And PZCal

#

theyre doing an equation to see by what number "X" should be multiplied so that the result is "X+2"

tawdry muskBOT
#

studio** You are now Level 7! **studio

granite yoke
#

The number by which it should be multiplied depends on the character's orientation.

#

when i try to run it

#

output says:

#
Players.EndeXiOficial.Backpack.stick.StickScript:122: attempt to perform arithmetic (mul) on number and nil