Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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

0
It works, thank you! Fixer1987 95 — 4y
Ad
Log in to vote
0
Answered by
Ghost40Z 118
4 years ago

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)
0
Still not working. The wave always faces another side! Fixer1987 95 — 4y

Answer this question