Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you teleport to a part when a value changes to another certain value?

Asked by 4 years ago
Edited 4 years ago

I am trying to figure out how to teleport to startingArea when a TextLabel changes its name to "Pumpkin Smash starts in: 00:10"

local startingArea = game:GetService("Workspace").Interiors.MainMap.PumpkinGame.Boundaries.SignupArea
game:GetService("Workspace").Interiors.MainMap.PumpkinGame.Boundaries.SignupArea.BillboardGui.TextLabel.Name.Changed:Connect(text)
    if text.Name == [[Pumpkin Smash starts in:
00:10]] then
HumanoidRootPart.CFrame = startingArea.CFrame
wait(11)
while true do wait(0.5)
for i, v in pairs(game:GetService("Workspace").StaticMap.PumpkinMinigame.SpawnedPumpkins.Pumpkin:GetDescendants()) do
  if v.name == "Collision" then
local Part = v
local A = 2  -- Amount/ 2 minimum
local Time = 0 -- Time between the single tp´s
local sX = game.Players.LocalPlayer.Character.HumanoidRootPart.Position.X
local sY = game.Players.LocalPlayer.Character.HumanoidRootPart.Position.Y
local sZ = game.Players.LocalPlayer.Character.HumanoidRootPart.Position.Z
-- With Parts
local eX = Part.Position.X
local eY = Part.Position.Y
local eZ = Part.Position.Z
-- With Position
--local eX,eY,eZ = -557.374084, 23.6536865, -1473.18372
-- with Position
local dX,dY,dZ = eX-sX,eY-sY,eZ-sZ -- Difference
local aX,aY,aZ = dX/A,dY/A,dZ/A -- Difference/Amount

for i = 1,A do
  wait(Time)
  if i==1 then
      game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(sX,sY,sZ)
  elseif i==A then
      game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(eX,eY,eZ)
  else
      game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new((sX+aX*i),(sY+aY*i),(sZ+aZ*i))
  end
end
end
end
end
wait(30)
while true do wait(0.5)
for i, v in pairs(game:GetService("Workspace").StaticMap.PumpkinMinigame.SpawnedPumpkins.Pumpkin:GetDescendants()) do
  if v.name == "Collision" then
local Part = v
local A = 2  -- Amount/ 2 minimum
local Time = 0 -- Time between the single tp´s
local sX = game.Players.LocalPlayer.Character.HumanoidRootPart.Position.X
local sY = game.Players.LocalPlayer.Character.HumanoidRootPart.Position.Y
local sZ = game.Players.LocalPlayer.Character.HumanoidRootPart.Position.Z
-- With Parts
local eX = Part.Position.X
local eY = Part.Position.Y
local eZ = Part.Position.Z
-- With Position
--local eX,eY,eZ = -557.374084, 23.6536865, -1473.18372
-- with Position
local dX,dY,dZ = eX-sX,eY-sY,eZ-sZ -- Difference
local aX,aY,aZ = dX/A,dY/A,dZ/A -- Difference/Amount

for i = 1,A do
  wait(Time)
  if i==1 then
      game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(sX,sY,sZ)
  elseif i==A then
      game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(eX,eY,eZ)
  else
      game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new((sX+aX*i),(sY+aY*i),(sZ+aZ*i))
  end
end
end
end
end
end
0
does the texts name start out as "Pumpkin Smash starts in: 00:10"? or does it constantly change? AntoninFearless 622 — 4y
0
it constantly changes because its a countdown Velcorii 13 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

TextLabel have a property called Text, and when it changes, it can detected by GetPropedtyChangedSignal. Here's a sample script, and all information you need to know to answer your question :

--// Variables
local textButton = script.Parent

--//Functions
local function onChanged()
        if textButton.Text == "Example" then
                -- Do your stuff
        end
end

--// Main
textButton:GetPropertyChangedSignal("Text"):Connect(onChanged)

In simple words, Changed and GetPropertyChangedSignal are kind of same, but the latter triggers on the change of mentioned property in " ".

Lemme know if it helps!

Ad

Answer this question