I made a gui and a joinhandler(with values and stuff) the gui has a script that gets information from some values
local tool = script.Parent.Parent.Parent.Tool local ammo = script.Parent.Parent.Parent.Tool.Ammo local gui = script.Parent local armor = script.Parent.Parent.Parent.Armor local clip = script.Parent.Parent.Parent.Tool.Clip while true do if tool.Value == "Hands" then gui.Index.Screen.Title.Text = "Hands - No Tool" gui.Index.Screen.Ammo.Visible = false gui.Index.Screen.Ammo2.Visible = false gui.Index.Screen.Controls.Visible = false gui.Index.Screen.LEFT.Visible = false gui.Index.Screen.RIGHT.Visible = false gui.Index.Screen.MODE.Visible = false gui.BG:TweenPosition(UDim2.new(1, -325, 1, -75)) gui.Index:TweenPosition(UDim2.new(1, -310, 1, -60)) elseif tool.Value == "Test" then gui.Index.Screen.Title.Text = "Test - ammothing" gui.Index.Screen.Ammo.Visible = true gui.Index.Screen.Ammo2.Visible = false gui.Index.Screen.Controls.Visible = true gui.Index.Screen.LEFT.Visible = false gui.Index.Screen.RIGHT.Visible = false gui.Index.Screen.MODE.Visible = true gui.Index.Screen.Ammo.Text = ammo.Value.."/"..clip.Value gui.BG:TweenPosition(UDim2.new(1, -325, 1, -125)) gui.Index:TweenPosition(UDim2.new(1, -310, 1, -110)) end if armor.Value == "0" then gui.Index2.Armor.Visible = false gui.Index2.ARMOR.Visible = false gui.BG:TweenPosition(UDim2.new(0, 0, 1, -75)) gui.Index:TweenPosition(UDim2.new(0, 20, 1, -60)) end end
the handler makes the values
function PlayerJoined(player) local Tool = Instance.new("StringValue",player) Tool.Name = "Tool" Tool.Value = "Hands" local GunAm = Instance.new("NumberValue",Tool) GunAm.Name = "Ammo" local GunClip = Instance.new("NumberValue",Tool) GunClip.Name = "Clip" local Armor = Instance.new("NumberValue",player) Armor.Name = "Armor" Armor.Value = 0 player:WaitForDataReady() local Money = player:LoadNumber("Money") local stats = Instance.new("IntValue", player) stats.Name = "leaderstats" local RankValue = Instance.new("StringValue", stats) RankValue.Name = "Rank" RankValue.Value = player:GetRoleInGroup(2532396) local MoneyValue = Instance.new("IntValue", stats) MoneyValue.Name = "Money" MoneyValue.Value = Money end game.Players.ChildAdded:connect(PlayerJoined)
can anyone tell me what goes wrong? because roblox freezes when I try to join(the loading screen freezes)
Explanation
Code
local tool = script.Parent.Parent.Parent.Tool local ammo = script.Parent.Parent.Parent.Tool.Ammo local gui = script.Parent local armor = script.Parent.Parent.Parent.Armor local clip = script.Parent.Parent.Parent.Tool.Clip while wait() do --you can use this, or the one below if tool.Value == "Hands" then gui.Index.Screen.Title.Text = "Hands - No Tool" gui.Index.Screen.Ammo.Visible = false gui.Index.Screen.Ammo2.Visible = false gui.Index.Screen.Controls.Visible = false gui.Index.Screen.LEFT.Visible = false gui.Index.Screen.RIGHT.Visible = false gui.Index.Screen.MODE.Visible = false gui.BG:TweenPosition(UDim2.new(1, -325, 1, -75)) gui.Index:TweenPosition(UDim2.new(1, -310, 1, -60)) elseif tool.Value == "Test" then gui.Index.Screen.Title.Text = "Test - ammothing" gui.Index.Screen.Ammo.Visible = true gui.Index.Screen.Ammo2.Visible = false gui.Index.Screen.Controls.Visible = true gui.Index.Screen.LEFT.Visible = false gui.Index.Screen.RIGHT.Visible = false gui.Index.Screen.MODE.Visible = true gui.Index.Screen.Ammo.Text = ammo.Value.."/"..clip.Value gui.BG:TweenPosition(UDim2.new(1, -325, 1, -125)) gui.Index:TweenPosition(UDim2.new(1, -310, 1, -110)) end if armor.Value == "0" then gui.Index2.Armor.Visible = false gui.Index2.ARMOR.Visible = false gui.BG:TweenPosition(UDim2.new(0, 0, 1, -75)) gui.Index:TweenPosition(UDim2.new(0, 20, 1, -60)) end wait(1) --wait before you end your while true do loop! end
Can't have a while true do
without a delay. Otherwise you're doing millions of commands at once. You need to put wait(seconds)
somewhere in that loop, or even put while wait() do
instead ofwhile true do
(don't ask how that works).