What I want to achieve: Each time any proximity prompt is activated, the script generates a new area. The cframe of the area is the cframe of the placeholders, which I have numbered. Each time a player activates the proximity prompt, the intvalue goes up by 1 and the textlabel updates to the intvalue’s number so the script knows what placeholder to put the area’s cframe as.
My Issue: Only the 1st area gets generated, the others don’t. In the developer console, it says "ServerScriptService.Generate:Line11: attempt to index nil with ‘CFrame’ "
---my script
local rooms = game.ReplicatedStorage:WaitForChild("GeneratedRooms"):GetChildren()
local textvalue = script.TextLabel.Text
local ProximityPromptService = game:GetService("ProximityPromptService")
ProximityPromptService.PromptTriggered:Connect(function()
local placeHolder = game.Workspace.Placeholders:FindFirstChild("R"..textvalue)
wait(2)
script.RoomNo.Value += 1
local chosenRoom = rooms[math.random(1,#rooms)]:Clone()
chosenRoom.PrimaryPart = chosenRoom.Floor
chosenRoom:SetPrimaryPartCFrame(placeHolder.CFrame)
wait(0.05)
placeHolder:Destroy()
chosenRoom.Parent = game.Workspace
end)
If anyone could help me, it would be greatly appreciated.