I'm having problems with this function. I'm not getting any errors here. I've tried putting the if statements into separate functions and connecting the functions on separate lines. For whatever reason, the entire function seems to stop detecting the touched event from the humanoid after the RoomTeleport statement. Here's the code:
local Character = script.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
local debounce = false
local Falling = nil
Character.Humanoid.Touched:Connect(function(hit)
if not debounce then
if hit.Name == "TeleportIslandPart" or hit.Name == "FallingTeleport" then
debounce = true
if hit.Name == "FallingTeleport" then
Falling = true
else
Falling = false
end
game.ReplicatedStorage.Teleport:FireClient(Player, Falling)
wait(3)
debounce = false
return end
if hit.Name == "RoomTeleport" then --the function stops working after this statement is done
debounce = true
local RoomName = hit.RoomName.Value
game.ReplicatedStorage.CreateRoom:FireClient(Player, RoomName)
wait(3)
debounce = false
return end
if hit.Name == "RoomLeave" then
debounce = true
local RoomName = hit.RoomName.Value
local Island = hit.Island.Value
game.ReplicatedStorage.LeaveRoom:FireClient(Player, RoomName, Island)
wait(3)
debounce = false
return end
end
end)
Here is the CreateRoom code:
local Player = game:GetService("Players").LocalPlayer
local Teleporting = false
game.ReplicatedStorage.CreateRoom.OnClientEvent:Connect(function(RoomName)
if not Teleporting then
Teleporting = true
local Room = game.ReplicatedStorage.Rooms[RoomName]
local Character = Player.Character
game.ReplicatedStorage.RequestAddLoadScreen:FireServer(RoomName, false, false, true)
wait(2)
Room.Parent = workspace
Player.Backpack.CurrentMusic.Value = Player.Backpack.MusicFolder[RoomName.."Music"]
Character.HumanoidRootPart.CFrame = workspace.TeleParts[RoomName.."TelePart"].CFrame
game.ReplicatedStorage.RequestRemoveLoadScreen:FireServer()
Teleporting = false
end
end)

7 comments
So the room teleport function works fully and then the script stops or the room teleport doesn't print anything?
that's right
Oh sry, i mistyped the last debounce as "true" again instead of false, try that, otherwise i'll look at it again in a bit
still not working. getting the same results
hmm, so does the "roomleave" work appropriately? The below should work, so it may be something with the client side local script, can you paste the portion pertaining to the CreateRoom remote onto your post?
LeaveRoom should be working properly, but it's just not firing. i've added the code for CreateRoom to the post
can you send a tc so i can have a look directly? since these seem to be fine, although i would use waitforchild / getservice in the createroom script, though if you dont have errors for it then idk where the issue is