So I made a script that teleports the player to another part if u touch a certain part. there are 2 parts, green and red. and if u touch red part u get teleported to a different part (not green part) the thing is I want it so if u spawn in and touch the red part, nothing happens and u need to touch the green part for that script to work.
game.Players.PlayerAdded:Connect(function(plr)
Instance.new("BoolValue",plr)
plr.BoolValue.Name = "TeleWork"
plr.TeleWork.Value = false
wait(5) -- how long u should wait for
plr.TeleWork.Value = true
end)
and you can check if TeleWork is true in your teleport script, and if it’s not true, it wont teleport
local players = game:GetService("Players")
local startPart = game:GetService("Workspace").StartPart --Change 'StartPart' to whatever your part is called.
local otherPart = game:GetService("Workspace").OtherPart --Change 'OtherPart' to whatever your part is called.
startPart.Touched:Connect(function(hit)
local plr = players:GetPlayerFromCharacter(hit.Parent)
if plr then
local HRP = plr.Character:WaitForChild("HumanoidRootPart")
HRP.CFrame = otherPart.CFrame
end
end)
If you don’t want anything to happen if you touch a certain part, then just don’t have a .Touched function for that specific part.
Is this supposed to teleport the player to the other part when touched, if so this is not what I mean. I explained it the best way as possible let me restate this again.
Here’s the parts with the scripts. (These scripts are not needed for this topic) and the part named “Part” is the part they will be teleported to.
Now… I have this script in the Stop.
Here’s what’s inside.
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local Teleport = "Part"
function Touch(hit) --Indicates that the Part has been Touched.
if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce.
local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to.
hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end --Takes you there and Ends the Function.
script.Parent.Touched:connect(Touch) --Listens out for Touchers.
end
So this script works, it teleports me to the part in workspace! The thing is…
I want it so if the “Start” part is touched THEN the script above works…
What I mean in short text:
If I spawn and touch the Stop part it doesn’t teleport me to the part. but if I touch the Start part and then touch the red part it teleports me.
Can you please read it right? Here’s what I’m trying to do PART 3. : /
So I have this script where if you touch the red part you get teleported to a other part (THIS PART IS NOT THE GREEN AND NOT THE RED PART, IT TELEPORTS THEM TO THE NORMAL PART that you can spawn easily.
I’m trying to make the TELEPORT script NOT WORK until I touch the GREEN PART.
Once I have touched the GREEN part the TELEPORT script starts working, so IF I touch the red part it teleport me to the NORMAL PART (NOT GREEN PART NOR RED)
What I’m supposed to get when I’ts done.
When I spawn and touch the red part I DON’T teleport.
BUT when I touch the GREEN part and then I touch the RED part I get teleported.
I’m very sorry for using too much BOLDS, CAPS. Etc… I’m just really stressed right now. I explained in the BEST and understandable WAY possible. but you don’t understand I really hope this makes sense for you.
I tried that, it didn’t work. Also if this doesn’t make sense to you then just stop helping me. I need someone that understands, I don’t have time to right another paragraph to someone who called this the most confusing way.
local StartTeleport = --the name of the block that starts the teleport
local EndTeleport = --the name of the block that you teleport to
StartTeleport.Touched:Connect(function(teleport)
if teleport.Parent:FindFirstChild("Humanoid") then
local char = teleport.Parent
local HumanoidRootPart = char.HumanoidRootPart
HumanoidRootPart.Position = EndTeleport.Position
end
end)
local part = script.Parent
local function onTouch(otherPart)
-- code goes here --
end
part.Touched:Connect(onTouch)
This usually works for me, put the code needed in the onTouch function.
To teleport:
local part = script.Parent
local teleportPart = --Instance of part goes here--
local function onTouch(otherPart)
if otherPart.Parent:IsA("Model") then
otherPart.Parent:SetPrimaryPartCFrame(TeleportPart.CFrame)
end
end
part.Touched:Connect(onTouch)