ok so i have a problem with my script that teleports players to a planet at a certain height
sometimes it doesnt show the gui for some players and sometimes it does how can i fix this?
local plrService = game:GetService(“Players”)
local plr = plrService.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
print("player addded "…tostring(plr.Name))
while true do
wait()
if char.HumanoidRootPart.Position.Y > 199999 then
script.Parent.Visible = true
script.Parent.TextLabel.Visible = true
else
script.Parent.Visible = false
script.Parent.TextLabel.Visible = false
while true do
wait()
char.Humanoid:GetPropertyChangedSignal("Position"):Connect(function()
if char.HumanoidRootPart.Position.Y > 199999 then
script.Parent.Visible = true
end
end)
end
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
Player.CharacterAdded:Connect(function(_Character)
Character = _Character
HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
end)
game:GetService("RunService").RenderStepped:Connect(function()
if Character then
if HumanoidRootPart then
if Character.HumanoidRootPart.Position.Y > 199999 then
script.Parent.Visible = true
script.Parent.TextLabel.Visible = true
else
script.Parent.Visible = false
script.Parent.TextLabel.Visible = false
end
end
end
end)