This script is somewhat working but the tween. completed is not working with the teleport. And the value is not changing
``
– Code
local RightDoor2 = workspace.Lobby[“Lobby Elevator”].RightDoor2
local TweenService = game:GetService(“TweenService”)
local RightDoorCloseInfo =TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out
)
local PropertyTable = {
[“Position”] = RightDoor2.Position
}
game.Players.PlayerAdded:Connect(function(player)
local Inlobby = player:FindFirstChild(“InLobby”)
script.Parent.Touched:Connect(function(char)
RightDoor2.CanCollide = true
for index, player in pairs(game.Players:GetPlayers()) do
local TweenRightDoorClose = TweenService:Create(workspace.Lobby["Lobby Elevator"].RightDoor, RightDoorCloseInfo, PropertyTable)
local character = player.Character or player.CharacterAdded:Wait()
wait(1)
TweenRightDoorClose:Play()
TweenRightDoorClose.Completed:Wait()
character.HumanoidRootPart.CFrame = workspace.Elevator.ElevatorPart.CFrame
RightDoor2.CanCollide = false
end
if Inlobby.Value ~= false then
local Humanoid = char:FindFirstChild("Humanoid", false)
if Humanoid then
Humanoid.Changed:Connect(function()
Inlobby.Value = false
end)
end
end
end)
end)
script.Parent.Touched:Connect(function(char)
Touched returns the BasePart (can also include Terrain) that was touched, not a character object.
You can get the humanoid and character like this:
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local character = humanoid and humanoid.Parent or nil
if character then
-- do stuff
end
end)
1 Like
The script worked for a second then when I tried it again it said "attempt to index nil with “value”.
local Inlobby = player:FindFirstChild(“InLobby”)
Maybe the player is having their InLobby value removed
Hmm there is nothing that removes it I don’t have any scripts that do that
Which line of code is erroring?
line 23 or if Inlobby.Value ~= false then
i fixed it using wait for child but it still won’t change the value
local Inlobby = player:WaitForChild(“InLobby”)
like this?
Yea it was FindFirstCHild but i changed it
Where is ‘InLobby’ being created?
Here is the full script
–
local RightDoor2 = workspace.Lobby[“Lobby Elevator”].RightDoor2
local TweenService = game:GetService(“TweenService”)
local RightDoorCloseInfo =TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out
)
local PropertyTable = {
[“Position”] = RightDoor2.Position
}
game.Players.PlayerAdded:Connect(function(player)
local Inlobby = player:WaitForChild(“InLobby”)
script.Parent.Touched:Connect(function(hit)
RightDoor2.CanCollide = true
for index, player in pairs(game.Players:GetPlayers()) do
local TweenRightDoorClose = TweenService:Create(workspace.Lobby["Lobby Elevator"].RightDoor, RightDoorCloseInfo, PropertyTable)
local character = player.Character or player.CharacterAdded:Wait()
wait(1)
TweenRightDoorClose:Play()
TweenRightDoorClose.Completed:wait()
character.HumanoidRootPart.CFrame = workspace.Elevator.ElevatorPart.CFrame
RightDoor2.CanCollide = false
end
if Inlobby.Value ~= false then
local Humanoid = hit:FindFirstChild("Humanoid", false)
local character = Humanoid
if Humanoid then
Inlobby.Value = false
end
end
end)
end)
i can give you the place file if you want
69420.rbxl (107.8 KB)
local Inlobby = player:WaitForChild(“InLobby”)
where is the value InLobby even being created?
It was in a different script
game.Players.PlayerAdded:connect(function(player)
Local inlobby = instance.new(“BoolValue”)
inlobby.name, Inlobby.Parent, in lobby.value = (“In lobby”, player, true
end)
There’s your issue
inlobby.name, Inlobby.Parent, in lobby.value = (“In lobby”,
it is named ''In lobby", not “Inlobby”
That might just be a mistype I I’ll tell you if it does not work