So, In my game I have some levels, each with a brick called "End". The following code is used:
function onTouch()
print ("End Active")
game.ServerStorage.Check.Value = "1"
wait (6)
game.ServerStorage.Check.Value = "0"
end
script.Parent.Touched:connect(onTouch)
"check" is a NumberValue. In my GUI, I have the following code:
script.Parent.Position = UDim2.new(0.5, 0, 0.5, 0) -- We set the scales to .5, .5, which is the center of the screen
script.Parent.Size = UDim2.new(0,0,0,0) -- We set the frame size too 0, so it will pop out of the middle of the screen.
local Value = game.ServerStorage.Check.Value
if (Value == "1") then
print ("Hello World!")
script.Parent.Visible = true
script.Parent:TweenSizeAndPosition(UDim2.new(0.3, 0, 0.1, 0), UDim2.new(.35, 0, .47, 0), "Out", "Quad", 1)
script.Parent.TextScaled = true
wait (3)
local torso = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Character.Torso
local destination = script.Parent.TeleportDestination.Value
torso.CFrame = CFrame.new(destination,torso.CFrame.lookVector)
print ("Player Teleported. Map Loading Complete. Removing GUI")
wait (2)
script.Parent.Visible = false
script.Parent.Parent.Main.lvlSelect.Visible = true
end
Script.Parent is a TextLable that I want to appear at the end of a level. I've got no clue what's wrong. I've had the 'if' statement work and had the code afterwards work in a different script. Both of the scripts are in Scripts and not LocalScripts, so any advice?

1 comment
It did help me. A lot. Thanks!