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

Models won't clone from lighting?

Asked by 9 years ago

So, In a test game I'm making, you spawn in a room. You touch a button, and it picks a room randomly from lighting, clones it in, teleports you to the room, and deletes the last room you were in. There's another button in the new room, which does the same thing as the last room (so its basically an endless assortment of rooms). This works fine in test mode, however in an actual server, it fails to work. When i hit the button, it teleports me to the middle of the baseplate, and no room spawns in. A singular script is incharge of the random room picking. This is the script:

01t = script.Parent
02 
03t.Changed:connect(function()
04    print("Changing Room...")
05    local r = math.random(1,3)
06    if r == 1 then
07        game.Lighting.defroom1:Clone().Parent = workspace
08        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom1.spawn.Position)
09        elseif r == 2 then
10        game.Lighting.defroom2:Clone().Parent = workspace
11        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom2.spawn.Position)
12        elseif r == 3 then
13        game.Lighting.defroom3:Clone().Parent = workspace
14        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom3.spawn.Position)
15    end
16end)

(NOTE: The script is located in Workspace > ValueHold (A folder I made) > RoomCount (A number Value) > This script)

0
I don't see an error in your script. Does the output show anything? Also, instead of keeping models in Lighting, use ServerStorage Validark 1580 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You can possibly try this, not sure if it'll work due to the fact I don't have anything to test it with.

01t = script.Parent
02defroom1 = game.Lighting.defroom1
03defroom2 = game.Lighting.defroom2
04defroom3 = game.Lighting.defroom3
05 
06t.Changed:connect(function()
07    print("Changing Room...")
08    local r = math.random(1,3)
09    if r == 1 then
10        game.Lighting.defroom1:Clone()
11        defroom1.Parent = game.Workspace
12        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom1.spawn.Position)
13        elseif r == 2 then
14        game.Lighting.defroom2:Clone()
15        defroom2.Parent = game.Workspace
View all 22 lines...
Ad

Answer this question