So anyways, I’ve noticed those “the [something] experience” horror games are becoming quite popular so I started making one myself. In the script below everything works except the part that involves the NPC sitting on the seat, it walks up to it but then just sorta stands inside of it, not sitting. What’s even stranger to me is that if I switch to server, while testing in studio the NPC does sit, however in client view it does not. How can I fix this.
local ReplicatedFirst = game:GetService("ReplicatedFirst")
ReplicatedFirst:RemoveDefaultLoadingScreen()
local sounds = game.Workspace:WaitForChild("Sounds")
local NPCFolder = game.ReplicatedStorage:WaitForChild('NPCS'):GetChildren()
local players = {}
local path1 = game.Workspace:WaitForChild("NPCPath1")
local path2 = game.Workspace:WaitForChild("NPCPath2")
local cards = game.Workspace:WaitForChild("Cards")
local brownCard = cards:WaitForChild("Brown")
local ChenCard = cards:WaitForChild("Chen")
local LingCard = cards:WaitForChild("Ling")
local seats = game.Workspace:WaitForChild("Seating"):WaitForChild("Seats"):WaitForChild("NpcSeats"):GetChildren()
local doctor = "holder"
local db = false
local function npc2reception()
local chosenNPC = NPCFolder[math.random(1,#NPCFolder)]
chosenNPC.Parent = workspace
task.wait(2)
local hum = chosenNPC:WaitForChild("Humanoid")
local pickPath = math.random(1,2)
if pickPath == 1 then
for i, v in pairs(path1:GetChildren()) do
print(1)
hum:MoveTo(path1:FindFirstChild(i).Position)
hum.MoveToFinished:Wait()
if i == 4 then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder").Visible = true
local chooseQuestion = math.random(1,3)
if chooseQuestion == 1 then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Hello, I need to see doctor Brown"
doctor = "Brown"
brownCard:WaitForChild("ProximityPrompt").Triggered:Connect(function()
if doctor == brownCard.Name then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Thanks"
task.wait(1.5)
doctor = "holder"
print("ran 2 seat")
local chosenSeat = seats[math.random(1,#seats)]
hum:MoveTo(chosenSeat.Position)
hum.MoveToFinished:Wait()
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder").Visible = false
chosenSeat:Sit(hum)
end
end)
elseif chooseQuestion == 2 then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Hello, I need to see doctor Chen"
doctor = "Chen"
ChenCard:WaitForChild("ProximityPrompt").Triggered:Connect(function()
if doctor == ChenCard.Name then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Thanks"
task.wait(1.5)
doctor = "holder"
print("ran 2 seat")
local chosenSeat = seats[math.random(1,#seats)]
hum:MoveTo(chosenSeat.Position)
hum.MoveToFinished:Wait()
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder").Visible = false
chosenSeat:Sit(hum)
end
end)
elseif chooseQuestion == 3 then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Hello, I need to see doctor Ling"
doctor = "Ling"
LingCard:WaitForChild("ProximityPrompt").Triggered:Connect(function()
if doctor == LingCard.Name then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Thanks"
task.wait(1.5)
doctor = "holder"
print("ran 2 seat")
local chosenSeat = seats[math.random(1,#seats)]
hum:MoveTo(chosenSeat.Position)
hum.MoveToFinished:Wait()
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder").Visible = false
chosenSeat:Sit(hum)
end
end)
end
break
end
end
elseif pickPath == 2 then
for i, v in pairs(path2:GetChildren()) do
print(i)
hum:MoveTo(path2:FindFirstChild(i).Position)
hum.MoveToFinished:Wait()
if i == 4 then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder").Visible = true
local chooseQuestion = math.random(1,3)
if chooseQuestion == 1 then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Hello, I need to see doctor Brown"
doctor = "Brown"
brownCard:WaitForChild("ProximityPrompt").Triggered:Connect(function()
if doctor == brownCard.Name then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Thanks"
task.wait(1.5)
doctor = "holder"
print("ran 2 seat")
local chosenSeat = seats[math.random(1,#seats)]
hum:MoveTo(chosenSeat.Position)
hum.MoveToFinished:Wait()
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder").Visible = false
chosenSeat:Sit(hum)
end
end)
elseif chooseQuestion == 2 then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Hello, I need to see doctor Chen"
doctor = "Chen"
ChenCard:WaitForChild("ProximityPrompt").Triggered:Connect(function()
if doctor == ChenCard.Name then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Thanks"
task.wait(1.5)
doctor = "holder"
print("ran 2 seat")
local chosenSeat = seats[math.random(1,#seats)]
hum:MoveTo(chosenSeat.Position)
hum.MoveToFinished:Wait()
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder").Visible = false
chosenSeat:Sit(hum)
end
end)
elseif chooseQuestion == 3 then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Hello, I need to see doctor Ling"
doctor = "Ling"
LingCard:WaitForChild("ProximityPrompt").Triggered:Connect(function()
if doctor == LingCard.Name then
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder"):WaitForChild("Question").Text = "Thanks"
task.wait(1.5)
doctor = "holder"
print("ran 2 seat")
local chosenSeat = seats[math.random(1,#seats)]
hum:MoveTo(chosenSeat.Position)
hum.MoveToFinished:Wait()
chosenNPC:WaitForChild("Head"):WaitForChild("Chat"):WaitForChild("Holder").Visible = false
chosenSeat:Sit(hum)
end
end)
end
break
end
end
end
end
local loopThread = coroutine.create(function()
while true do
task.wait(0.1)
print("loop")
if players[1] == nil then
print("break")
game.ReplicatedStorage.DoneLoading:FireAllClients()
print("everyone done loading")
break
else
end
end
print("ran")
task.wait(8)
game.Workspace:WaitForChild("Phone"):WaitForChild("Base"):WaitForChild("Pickup").Enabled = true
game.Workspace:WaitForChild("Phone"):WaitForChild("Base"):WaitForChild("UI"):WaitForChild("Image").Visible = true
sounds:WaitForChild("Phone Ring"):Play()
end)
game.Workspace:WaitForChild("Phone"):WaitForChild("Base"):WaitForChild("Pickup").Triggered:Connect(function()
game.Workspace:WaitForChild("Phone"):WaitForChild("Base"):WaitForChild("Pickup").Enabled = false
game.Workspace:WaitForChild("Phone"):WaitForChild("Base"):WaitForChild("UI"):WaitForChild("Image").Visible = false
sounds:WaitForChild("Phone Ring"):Stop()
sounds:WaitForChild("phone_pickup"):Play()
task.wait(3)
npc2reception()
end)
game.Players.PlayerAdded:Connect(function(player)
game.ReplicatedStorage.StartLoading:FireClient(player)
table.insert(players, player)
coroutine.resume(loopThread)
player.CharacterAppearanceLoaded:Connect(function()
if not db then
db = true
table.remove(players,table.find(players, player))
task.wait()
db = false
end
end)
end)