So I have a server script inside a radio where when the radio’s proximity prompt is triggered, it will play a sound, when the sound is finished, the lights will turn off and the game will teleport the player by getting the character and doing SetPrimaryPartCFrame to a pad about 2 seconds later, here is the script:
local radio = script.Parent
local dialogue = radio.Dialogue
local proximity = radio.ProximityPrompt
local light = game.Workspace:WaitForChild("darkroomlight").Model.Model.Bulb.PointLight
local JailedOfficePad = game.Workspace.JailedOfficePad
local currentlyTeleporting = game.StarterPlayer.StarterCharacterScripts.currentlyTeleporting
debounce = false
proximity.Triggered:Connect(function(triggered)
proximity.Enabled = false
dialogue:Play()
dialogue.Ended:Wait()
task.wait(2)
light.Enabled = false
task.wait(2)
print("woohooo")
if triggered and triggered.Parent and triggered.Character:FindFirstChildWhichIsA("Humanoid") and currentlyTeleporting.Value == false then
local Character = triggered.Character
local teleportLocation = CFrame.new(JailedOfficePad.CFrame.X, JailedOfficePad.CFrame.Y + 5, JailedOfficePad.CFrame.Z)
local player = game.Players:GetPlayerFromCharacter(triggered.Parent)
local teleportingValue = currentlyTeleporting
Character:SetPrimaryPartCFrame(teleportLocation)
local teleportingValue = currentlyTeleporting
teleportingValue.Value = true
script:Destroy()
debounce = false
end
end)
The problem I’m facing with this is that the script stops working mid way (after the lights turn off) and fails to teleport you. I discovered that the line
if triggered and triggered.Parent and triggered.Character:FindFirstChildWhichIsA("Humanoid") and currentlyTeleporting.Value == false then
was causing this due to the way it was placed in the script, and when I removed it, the script DID teleport you to the pad, but the character ends up no clipping through the floor for some weird reason after teleported even though the floor has CanCollide enabled. Here’s a clip of what it looked like before said line was removed from the script:
And here’s a clip after the line was cleared from where it was:
I’m not sure why it’s doing this if it doesn’t do this with the other teleportation pads that also have the same script (just without the line deleted). All that was changed here was
if triggered and triggered.Parent and triggered.Character:FindFirstChildWhichIsA("Humanoid") and currentlyTeleporting.Value == false then
getting removed and also removing the end that was at the bottom of the script. Here’s the pad that you get teleported on:
I don’t think that it’s too low and that being the reason why it’s making the character fall through the floor as I have other teleportation pads (just with the line not deleted) also placed like this on the ground and you get teleported on top of it with no problem. I tried raising it a bit higher this time but the script still seems to clip the player through the ground! I’d really really appreciate your help on this as I’ve been stressing over it a bit for the past few days knowing it’s something so simple which I can’t seem to fix.
Character:MoveTo simply moves. or teleports the player, not to be confused with Character.Humanoid:MoveTo, they work the same way except one teleports the player, but both dont require the PrimaryPart.
“The problem I’m facing with this is that the script stops working mid way (after the lights turn off) and fails to teleport you. I discovered that the line”
I think the reason why that happened is because you were destroying the script shortly after
if triggered and triggered.Parent and triggered.Character:FindFirstChildWhichIsA("Humanoid") and currentlyTeleporting.Value == false then
local Character = triggered.Character
local teleportLocation = CFrame.new(JailedOfficePad.CFrame.X, JailedOfficePad.CFrame.Y + 5, JailedOfficePad.CFrame.Z)
local player = game.Players:GetPlayerFromCharacter(triggered.Parent)
local teleportingValue = currentlyTeleporting
Character:SetPrimaryPartCFrame(teleportLocation)
local teleportingValue = currentlyTeleporting
teleportingValue.Value = true
**script:Destroy()**
debounce = false
end
You could also then use this instead for teleporting the player to the part
The Script runs everything except debounce due to it being after script:Destroy(), Therefore it wont set to false as the script will be destroyed before it can do it.
So that shouldnt be the case unless debounce is important.
It could just simply be the way the part is positioned but I really don’t see anything else in the script that would cause the player to fall through the ground.
@CreativityMen@EchoWinds
Not sure if this is a better why of doing it but it automatically teleports the Player without needing a HumanoidRootPart
I dont use HumanoidRootPart to teleport players as it has its own set of issues moving it so it may not be as i think but it is a way of Teleportation.
Most definitely should use :PivotTo(), so that you ensure you will be teleported to the exact location, and MoveTo, will try to position you as near to the position accounting for collision.
The trick is, however, to make sure you adjust the Y value of the teleport destination based on the size of the character.
lets assume teleport destination is x,y,z
for the y do
y + Humanoid.HipHeight + (HumanoidRootPart/2) +.5 this should teleport the character .5 studs above the destination (the reason I add a .5 is because most teleport destinations are centered on a 1 stud thick (in y direction) block, so .5 extra is needed to account for the target position being .5 studs into the target block.
I forgot to add, that even if a part is solid, and can collide, if you pivot to with cframe into it, you will fall through it, that is why it is important to make sure you teleport ‘above’ the target block.
Sorry for the late reply, DevForum site was acting goofy.
Ok, so the position of the part in my game is in 1535.31, -307.61, 421.614 now, it’s high enough off the ground for the player to definitely spawn at. How would exactly would I set it up in the script so you get teleported like that? I had tried doing
local teleportLocation = JailedOfficePad.Position + Vector3.new(1535.31, -307.61, 421.614)
But that just made you spawn WAAAY off and killed you.
I also changed
local teleportLocation = CFrame.new(JailedOfficePad.CFrame.X, JailedOfficePad.CFrame.Y + 5, JailedOfficePad.CFrame.Z)
to
as suggested. Sorry, still a bit confused as it didn’t seem to work.
Nope, just tried making it much thicker and you still fall through. The dark room in the beginning of the clip has a thin floor about as thin as the office one and you don’t fall through that one when they also use the same script for teleportation to locations.
local teleportLocation = JailedOfficePad.Position
character:MoveTo(teleportLocation + Vector3.new(0,2,0))
You Don’t Add a Position to a Position, in this case, you just add 2y and you wont spawn inside the part
Method 2
local teleportLocation = Vector3.new(1535.31, -310.56, 421.614)
character:MoveTo(teleportLocation)
In this example, you can just use Position, this isn’t the most efficient way due to you have to change it when you make a change to the game but it works either way.
You dont need to do this. either way it does the same thing as teleportLocation.Position
I tried to make a copy with your example and made some changes to the script, and it seems to work.
See if this helps you any. RadioPlaysAndTeleports.rbxl (39.1 KB)
The script had some checks that were not necessary, also ‘where’ you were checking was out of place.
local radio = script.Parent
local dialogue = radio.Dialogue
local proximity = radio.ProximityPrompt
local light = game.Workspace.Bulb.SpotLight
local JailedOfficePad = game.Workspace.JailedOfficePad
proximity.Triggered:Connect(function(triggered)
local Character = triggered.Character
if Character and Character:FindFirstChildWhichIsA("Humanoid") and not Character:GetAttribute("TeleportingValue") then
Character:SetAttribute("TeleportingValue",true)
proximity.Enabled = false
dialogue:Play()
dialogue.Ended:Wait()
task.wait(2)
light.Enabled = false
task.wait(2)
print("woohooo")
local teleportLocation = JailedOfficePad.CFrame+Vector3.new(0,Character.Humanoid.HipHeight + (Character.PrimaryPart.Size.Y/2) +.5)
Character:PivotTo(teleportLocation)
script:Destroy()
end
end)
LOL, turns out that the whole time it wasn’t even the script it was a part in Workspace that was covering the entire office which made you fall down after you teleported in.