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

How to let a block stay infront of player?

Asked by 4 years ago

hello beautiful people hope you are having a blessed day i'm making so if the thing is equipped the wall is in front if the player but it is always just next to the player can somebody please help

(ps. I want it to work on a model)

here is the script

script.Parent.Equipped:Connect(function()
    script.Parent.Value.Value = false
    wait(0.01)
    local building = game.Players.LocalPlayer.PlayerGui.building.Value
    local clone  = game.ReplicatedStorage[building]:Clone()
    clone.Parent = game.Workspace
    clone.Name = script.Parent.Parent.Name.."'s object"
    wait(0.01)
    repeat
        local x = script.Parent.Parent.HumanoidRootPart.Orientation.X
        local y = script.Parent.Parent.HumanoidRootPart.Orientation.Y
        local z = script.Parent.Parent.HumanoidRootPart.Orientation.Z
    clone.PrimaryPart.Position = Vector3.new(Vector3.new(0,0,5) + game.Players.LocalPlayer.Character.HumanoidRootPart.Position)
    clone:SetPrimaryPartCFrame(CFrame.Angles(x,y,z))
        wait(0.1)
    until script.Parent.Value.Value == true

i have alot alot more script but that is the part i have it to follow the player...

help?

1 answer

Log in to vote
0
Answered by
EthanFins 104
4 years ago

I would weld it to the players HumanoidRootPart by doing something like this

local Weld = Instance.new("WeldConstraint",script.Parent.Parent.HumanoidRootPart)
script.Parent.Parent.HumanoidRootPart.CFrame = -- Replace with your modle
Modle.CFrame = HumanoidRootPart.CFrame +(script.Parent.CFrame.lookVector * .01)
Weld.Part0 = script.Parent.Parent.HumanoidRootPart
Weld.Part1 = -- Modle

Hope I helped!

0
yes i don't know if it will work but at line 3 "script.Parent.CFrame.lookVector" what to you want to select with "script.Parent" because now it select the tool =/ GamerJanko 50 — 4y
Ad

Answer this question