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

Not able to make a part which spawns in front of me face the same way I am facing?

After giving some checks on a few script examples, I managed to write a script that makes a Wave union appear in front of me; however, I am not able to make it face the way I am facing! It faces another way, I will leave some links to show you.

-LocalScript inserted in ScreenGui.

local players = game:GetService("Players")
local mouse = game.Players.LocalPlayer:GetMouse()
local bool = false
local plr = players.LocalPlayer

mouse.KeyDown:connect(function(k)
	k = k:lower()
	if k == 'z' then
		if bool == false then
			game.ReplicatedStorage.GodsPowers.Amphitrite:FireServer(plr)
			bool = true
		else
			wait(3)
			bool = false
		end
	end
end)

-Script inserted in a Folder in workspace.

game.ReplicatedStorage.GodsPowers.Amphitrite.OnServerEvent:Connect(function(plr)
	local a = script.TsunamiWave
	local Torso = plr.Character.Torso
	local pos = plr.Character.HumanoidRootPart.Position+ plr.Character.HumanoidRootPart.CFrame.LookVector*5 
	a.Anchored = true
	a.Position = Torso.Position + Torso.CFrame.lookVector * 20
	a.CFrame = CFrame.new(pos,plr.Character.HumanoidRootPart.Position)
end)

These are the pictures!

https://gyazo.com/69baed6634a27185129ebc70265e9a92 https://gyazo.com/00e6c90c3e32ae2a18fb8c63ba2cb085

2 answers

✓ Accepted answer

In The script for Workspace, You need to add a line that Sets the CFrame Rotations.

a.CFrame = a.CFrame * CFrame.Angles(math.rad(0), math.rad(90), math.rad(0)) -- should offset while keeping rotations of root.CFrame

CFrame.Angles Will Help with Facing the Wave Correctly for Which User they are Facing towards.

Demo Here! https://gyazo.com/fe1c3e2954330e02915e1d2c1b8ba956

1 comment

0

It works, thank you!

In the script in the workspace, you need to add a line to set the orientation.

game.ReplicatedStorage.GodsPowers.Amphitrite.OnServerEvent:Connect(function(plr)
    local a = script.TsunamiWave
    local Torso = plr.Character.Torso
    local pos = plr.Character.HumanoidRootPart.Position+ plr.Character.HumanoidRootPart.CFrame.LookVector*5 
    a.Anchored = true
    a.Position = Torso.Position + Torso.CFrame.lookVector * 20
    a.CFrame = plr.Character.HumanoidRootPart.CFrame
    a.Orientation = Torso.Orientation
end)

1 comment

0

Still not working. The wave always faces another side!

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