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

Making A Get A Snack at 3Am type game. Can Somebody Help?

Asked by 2 years ago
Edited 2 years ago

so basically im new to scripting but really trying to learn and my first goal is to make a game. Basically what im trying to do is make a loop for the cashier where he goes to the breakroom and then comes back. But I cant get him to clone back, and even if I do I cant change the position with vector3

Heres my script

while true  do

wait(6)
local PathfindingService = game:GetService("PathfindingService")

local Humanoid = script.Parent.Humanoid
local Root = script.Parent:FindFirstChild("HumanoidRootPart")
local goal = game.Workspace.EndingPart.Position
local breakroom = game.Workspace.BreakRoom.Model
local breakroom = game.Workspace.BreakRoom.Model.Door
local breakroom2 = game.Workspace.BreakRoom.Model.Handle
local tod = game.Workspace.Tod
local sound = script.Parent.sound
local sound2 = game.Workspace.sound2E
local todClone = game.ReplicatedStorage
local sound3 = game.Workspace.sound3



local path = PathfindingService:CreatePath()

path:ComputeAsync(Root.Position, goal)

local waypoints = path:GetWaypoints()

for i, waypoint in ipairs(waypoints) do
    Humanoid:MoveTo(waypoint.Position)

    if waypoint.Action == Enum.PathWaypointAction.Jump then
        Humanoid.Jump = true
    end

    Humanoid.MoveToFinished:Wait()
end

wait(1)
breakroom.CFrame = CFrame.new(709.197, 4.065, 655.979) * CFrame.Angles(0, -26.3, 0)
breakroom2.CFrame =CFrame.new(710.407, 4.199, 657.698) * CFrame.Angles(0, 156.24, 0)
sound:Play()
wait(3)
tod:Destroy()
wait(1)
sound2:Play()
breakroom.Position = Vector3.new(707.419, 4.065, 651.726)
breakroom.Orientation = Vector3.new(0, 89.31, 0)
breakroom2.Position = Vector3.new(708.148, 4.199, 650.094)
breakroom2.Orientation = Vector3.new(0, 91.69, 0)

wait(3)

    function GetTodOnLoop ()
        local CloneTod = game.ReplicatedStorage.Tod
        CloneTod:Clone()
        CloneTod.Position = Vector3.new(game.Workspace.SpawnTod.Position)
        CloneTod.Parent = game.Workspace.SpawnTod





end 



end

1 answer

Log in to vote
0
Answered by 2 years ago

Buddy to change a Models CFrame you have to do is;

local Cframe = nil -- CFrame Here
local TodModel = nil -- reference to tods model

TodModel:SetPrimaryPartCFrame(Cframe)

Models don't have a Cframe or Position so to Change the Position you have to change the primary part Cframe. I hope this helps :)

Ad

Answer this question