I want that, upon a proximity prompt be activated, the npc teleports to the room which has the name “Room(NumberValue)”, the number value goes up by 1 each time a proximity prompt is added as well. So it should teleport in each unique room. All rooms have the “NPCSpawn” part inside of them.
I am not sure what the issue here is, but it says it can’t index number from NPCSpawn in the Developer Console.
script:
local debounce = false
game:GetService("ProximityPromptService").PromptTriggered:Connect(function()
if not debounce then
debounce = true
wait(0.01)
local NPCClone = game.ReplicatedStorage.NPC:Clone()
NPCClone.Parent = game.Workspace.NPCs --folder
NPCClone.Humanoid.RootPart.CFrame = game.Workspace["Room"]..game.ReplicatedStorage.RoomNo.Value.NPCSpawn.CFrame --This is the part that is bugged
wait(35)
debounce = false
NPC:Destroy()
end
end)
Anyone who can help would be a life saver!