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 8 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:

t = script.Parent

t.Changed:connect(function()
    print("Changing Room...")
    local r = math.random(1,3)
    if r == 1 then
        game.Lighting.defroom1:Clone().Parent = workspace
        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom1.spawn.Position)
        elseif r == 2 then
        game.Lighting.defroom2:Clone().Parent = workspace
        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom2.spawn.Position)
        elseif r == 3 then
        game.Lighting.defroom3:Clone().Parent = workspace
        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom3.spawn.Position)
    end
end)

(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 — 8y

1 answer

Log in to vote
0
Answered by 8 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.

t = script.Parent
defroom1 = game.Lighting.defroom1
defroom2 = game.Lighting.defroom2
defroom3 = game.Lighting.defroom3

t.Changed:connect(function()
    print("Changing Room...")
    local r = math.random(1,3)
    if r == 1 then
        game.Lighting.defroom1:Clone()
        defroom1.Parent = game.Workspace
        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom1.spawn.Position)
        elseif r == 2 then
        game.Lighting.defroom2:Clone()
        defroom2.Parent = game.Workspace
        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom2.spawn.Position)
        elseif r == 3 then
        game.Lighting.defroom3:Clone()
        defroom3.Parent = game.Workspace    
        game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom3.spawn.Position)
    end
end)
Ad

Answer this question