New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Getting A Model To Follow A Player?

Asked by
Donut792 198
10 days ago

alright so i was trying to create myself a simple system to place a shack down and i got it to be able to place where the player is at but im wanting it to be relitively close to the player but in front of the player but what i am getting right now is the model placing on the player and keep in mind this game is going to be in first person so you can imagine how bad that is

anyways here is what i got for it so far Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
-- note to self make sure tool is not requires handle
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Mouse = Player:GetMouse()
local Shack = ReplicatedStorage:FindFirstChild("Shack")
local debounce = false
Tool.Equipped:Connect(function()
    --RunService.RenderStepped:Connect(function(step)
        local ShackClone = Shack:Clone()
        ShackClone.Parent = workspace
        ShackClone.Name = "ShackBluePrint"
--      while true do
--          if debounce == false then
--              debounce = true
                ShackClone:SetPrimaryPartCFrame(CFrame.new(HumanoidRootPart.Position),HumanoidRootPart.CFrame.lookVector * 100)
                ShackClone:SetPrimaryPartCFrame(ShackClone:GetPrimaryPartCFrame()*CFrame.fromEulerAnglesXYZ(0,0,Head.CFrame.lookVector.Y))
--              wait(2)
--              debounce = false
            --
            --end
        --end
    --end)
end)

Tool.Unequipped:Connect(function()
    workspace.ShackBluePrint:Destroy()
end)

Tool.Activated:Connect(function()
    local PositionClicked = Mouse.hit.p
    if Mouse.Target.Name == "Shack" then
    else
    local posX, posY, posZ = PositionClicked.X, PositionClicked.Y, PositionClicked.Z
    game.ReplicatedStorage.PlaceFabrication:FireServer(posX, posY, posZ)
    end
end)

all the comments were an attempt to get it to follow the player but always resulted in script timeouts no matter how many different ways i set it up

0
Either use endered step or while loop not both. Make sure to have a wait(). royaltoe 2543 — 9d
0
Also add an offset BlackOrange3343 2653 — 9d

Answer this question