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

IDK how this script work. Why does it have no surface property? Read Description.

local redBlock = game.Workspace.RedBlock
local blueCube = game.Workspace.BlueCube
 
-- Create a Vector3 for both the start position and target position
local startPosition = Vector3.new(0, 3, 0)
local targetPosition = blueCube.Position
 
-- Put the red block at 'startPosition' and point its front surface at 'targetPosition'
redBlock.CFrame = CFrame.new(startPosition, targetPosition)

Script taken from Dev Hub; Understading Cframes; https://developer.roblox.com/en-us/articles/Understanding-CFrame

The script makes the Redblock front Surface point to the BlueBlock Cframe, but there is no Surface property in the script. How does it work?

2 comments

0

Do you want to do something with the surface? I'm a bit confused at what you want it to do.

0

You can check out the Wiki Description of what the script does in the link. It pretty much explain it.

1 answer

✓ Accepted answer

Your wording is a bit confusing

But the script that you show have nothing to do with surface or surface property

redBlock.CFrame = CFrame.new(startPosition, targetPosition)

it is a functionality of CFrame that takes 2 vector3 parameter, where it simply move redBlock to startPosition' and make redBlockface towardtargetPosition`

2 comments

0

When I tried ray casting for an auto turret, the turret who is supposed to face the humanoid when it gets within 50studs would face it only with a specific side. So when I first did it, it was facing it with its long side and the direction is offset by 90 degrees. Is it always the front surface that point to the target? How do you code it so that its different side?

0

Depending on which side you want, u can just rotate it by -90,90 for left and right, or 180 for the back, and yes the front will be the one facing the target

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