Earlier, I made a topic about how the animations for my tables were bugging out. Now theres a new problem. Whenver a room is generated, they will just stop functioning completely. However if I were able to just put the room in workspace, the tables work perfectly.
Hiding script:
local ts = game:GetService("TweenService")
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
repeat task.wait() until plr and char and script.Parent.HidePrompt and script.Parent.ExitPrompt and script.Parent.Parent.Parent
local idle = char:WaitForChild("Humanoid"):LoadAnimation(script.Parent.Idle)
local enter = char:WaitForChild("Humanoid"):LoadAnimation(script.Parent.Enter)
local exit = char:WaitForChild("Humanoid"):LoadAnimation(script.Parent.Exit)
script.Parent.HidePrompt.Triggered:Connect(function()
print("triggered")
plr.Character.HumanoidRootPart.Anchored = true
script.Parent.In:Play()
local tween = ts:Create(plr.Character.HumanoidRootPart,TweenInfo.new(0.5,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out),{CFrame = script.Parent.CFrame + Vector3.new(0,1,0)})tween:Play()
wait(0.5)
print("Tween completed!")
plr.Character:SetAttribute("hiding",true)
script.Parent.Parent.IsPlayerInLocker.Value = 1
script.Parent.HidePrompt.Enabled = false
script.Parent.ExitPrompt.Enabled = true
enter:Play()
print("Enter animation playing.")
enter.Ended:Wait()
print("Enter animation ended, idle should be playing now!")
idle:Play()
end)
script.Parent.ExitPrompt.Triggered:Connect(function()
print("triggered")
script.Parent.Out:Play()
local tween = ts:Create(plr.Character.HumanoidRootPart,TweenInfo.new(0.5,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out),{CFrame = script.Parent.CFrame + Vector3.new(0,1,0)})tween:Play()
wait(0.5)
idle:Stop()
--plr.Character.HumanoidRootPart.CFrame = script.Parent.Parent.Parent.ExitCFRAME.CFrame -- i need to add parts
script.Parent.Parent.IsPlayerInLocker.Value = 0
--local tween2 = ts:Create(script.Parent.Parent,TweenInfo.new(0.5,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{CFrame = script.Parent.Parent.Parent.DoorClosed.CFrame})tween2:Play()
plr.Character.HumanoidRootPart.Anchored = false
plr.Character:SetAttribute("hiding",false)
script.Parent.ExitPrompt.Enabled = false
script.Parent.HidePrompt.Enabled = true
exit:Play()
end)
end)
end)
Room generation script:
local ambient = 255
local lighting = game:WaitForChild("Lighting")
local event = game:GetService("ReplicatedStorage"):WaitForChild("Generate")
event.Event:Connect(function(currentRoom)
local newroom : Model = game.ServerStorage.Isdfjhfd:GetChildren()[math.random(1, #game.ServerStorage.Isdfjhfd:GetChildren())]:Clone()
ambient = ambient - 4
workspace.Workspacethings.curroom.Value = newroom
workspace.Workspacethings.Current.Value = workspace.Workspacethings.Current.Value + 1
workspace.Workspacethings.curroom.Value.label.sg.text.Text = workspace.Workspacethings.Current.Value
lighting.Ambient = Color3.fromRGB(ambient, ambient, ambient)
lighting.OutdoorAmbient = Color3.fromRGB(ambient,ambient,ambient)
newroom.Parent = workspace.Rooms
newroom:PivotTo(currentRoom.EndPart.CFrame)
workspace.Thingies.front.Position = workspace.Workspacethings.curroom.Value.door.Position
print("omg")
end)