So I am using this code to make it so a dino hatches from an egg with a random choice and then goes to a point on the map that is its designated spawn point. Before I used this part of the script to bring the 'dino' to 'Spawn-
local dino=game.ServerStorage[randomchoice]:Clone() dino.Parent=workspace dino.Torso.CFrame=egg.CFrame*CFrame.new(0,2,0) if script.Parent.Parent.Name=="Model" then script.Parent.Parent.Nest.BillboardGui.Text.Text=("a "..randomchoice.." was hatched from a "..egg.ID.Value.."!") elseif script.Parent.Parent.Name=="Inc" then egg.Parent.Parent.Parent.Screen.SurfaceGui.TextLabel.Text=("a "..randomchoice.." was hatched from a "..egg.ID.Value.."!") end wait(0.2) dino.Torso.CFrame=workspace.Habitats[script.Parent.Player.Value].Spawn.CFrame*CFrame.new(2,2,2)
Which works correctly but all the dinos go to the same spot. It uses the random choice which gets called dino and brings it to a part on the map called Spawn. I changed the script so that it changes the place the dino goes depending on the dino but the code looks fine has no errors or underlines and doesnt give an error in output. Heres the current code-
local Trike = game.ServerStorage.Trike local Dilo = game.ServerStorage.Dilophosaurus local Pachy1 = game.ServerStorage.Pachy1 local Pachy2 = game.ServerStorage.Pachy2 local Compy1 = game.ServerStorage.Compy1 local Compy2 = game.ServerStorage.Compy2 local Coeluro = game.ServerStorage.Coelurosaur local random local randomchoice local function makebaby(egg) random=math.random(0,1000) if random <= 150 then randomchoice = "Dilophosaurus" --15% print ("Dilophosaurus Hatched!") elseif random <= 300 and random >= 150 then --15% randomchoice = "Pachy1" print ("Pachy1 Hatched!") elseif random <= 400 and random >= 30 then --10% randomchoice = "Pachy2" print ("Pachy2 Hatched!") elseif random <= 550 and random >= 400 then --15% randomchoice = "Trike" print ("Triceratops Hatched!") elseif random <= 700 and random >= 55 then --15% randomchoice = "Coelurosaur" print ("Coelurosaur Hatched!") elseif random <= 850 and random >= 700 then --15% randomchoice = "Compy1" print ("Compy1 Hatched!") elseif random <=1000 and random >= 850 then --15% randomchoice = "Compy2" print ("Compy2 Hatched") end local dino=game.ServerStorage[randomchoice]:Clone() dino.Parent=workspace dino.Torso.CFrame=egg.CFrame*CFrame.new(0,2,0) if script.Parent.Parent.Name=="Model" then script.Parent.Parent.Nest.BillboardGui.Text.Text=("a "..randomchoice.." was hatched from a "..egg.ID.Value.."!") elseif script.Parent.Parent.Name=="Inc" then egg.Parent.Parent.Parent.Screen.SurfaceGui.TextLabel.Text=("a "..randomchoice.." was hatched from a "..egg.ID.Value.."!") end wait(0.2) if randomchoice==Pachy1 then Pachy1.Torso.CFrame=workspace.Habitats[script.Parent.Player.Value].Pachy1Spawn.CFrame*CFrame.new(2,2,2) elseif randomchoice==Pachy2 then Pachy2.torso.CFrame=workspace.Habitats[script.Parent.Player.Value].Pachy2Spawn.CFrame*CFrame.new(2,2,2) elseif randomchoice==Compy1 then Compy1.torso.CFrame=workspace.Habitats[script.Parent.Player.Value].Compy1Spawn.CFrame*CFrame.new(2,2,2) elseif randomchoice==Compy2 then Compy2.torso.CFrame=workspace.Habitats[script.Parent.Player.Value].Compy2Spawn.CFrame*CFrame.new(2,2,2) elseif randomchoice==Trike then Trike.torso.CFrame=workspace.Habitats[script.Parent.Player.Value].TrikeSpawn.CFrame*CFrame.new(2,2,2) elseif randomchoice==Dilo then Dilo.torso.CFrame=workspace.Habitats[script.Parent.Player.Value].DiloSpawn.CFrame*CFrame.new(2,2,2) elseif randomchoice==Coeluro then Coeluro.torso.CFrame=workspace.Habitats[script.Parent.Player.Value].CoeluroSpawn.CFrame*CFrame.new(2,2,2) end egg:Destroy() end makebaby(script.Parent)
There are spots in the map Which each spawn name. For example a block called Pachy1Spawn and TrikeSpawn exist but the dinos just sit where the egg was and dont go to any spawn and no error is seen. Any help would be very helpful thanks!