Hello, I'm currently editing an radio and I have 1 problem with the UpdateScript:
wait(1) MainGUI = script.Parent GUI = MainGUI.Frame Tool = MainGUI.Tool function Update() connectedchannel = script.Parent.Frame.Network.CNetwork.Value Channel = game.Workspace:FindFirstChild(connectedchannel) GUI.Line1.Text = Channel.Line1.Value GUI.Line2.Text = Channel.Line2.Value GUI.Line3.Text = Channel.Line3.Value GUI.Line4.Text = Channel.Line4.Value GUI.Line5.Text = Channel.Line5.Value GUI.Line6.Text = Channel.Line6.Value GUI.Line7.Text = Channel.Line7.Value Tool.Value.Handle.Alert.Volume = 0.4 Tool.Value.Handle.Alert.Run.Value = true end Channel.Line7.Changed:connect(Update) wait(0.2) Update()
When I equip the radio it says the following: Players.Player.PlayerGui.OfficerRadio.UpdateScript:22: attempt to index global 'Channel' (a nil value) Stack Begin Script 'Players.Player.PlayerGui.OfficerRadio.UpdateScript', Line 22 Stack End
My buddy and I can't solve the problems.
Channel is not defined until the function Update() runs. The function only runs in an event that can not be triggered since Channel does not exist yet according to your script.
wait(1) MainGUI = script.Parent GUI = MainGUI.Frame Tool = MainGUI.Tool local connectedchannel = ''; Channel = game.Workspace:findFirstChild(connectedchannel); function Update() connectedchannel = script.Parent.Frame.Network.CNetwork.Value GUI.Line1.Text = Channel.Line1.Value GUI.Line2.Text = Channel.Line2.Value GUI.Line3.Text = Channel.Line3.Value GUI.Line4.Text = Channel.Line4.Value GUI.Line5.Text = Channel.Line5.Value GUI.Line6.Text = Channel.Line6.Value GUI.Line7.Text = Channel.Line7.Value Tool.Value.Handle.Alert.Volume = 0.4 Tool.Value.Handle.Alert.Run.Value = true end Channel.Line7.Changed:connect(Update) wait(0.2) Update()
My friend did it on a different way, Posting here, Maybe we could help some people :D
wait(1) MainGUI = script.Parent GUI = MainGUI.Frame Tool = MainGUI.Tool Channel1Model = game.Workspace:FindFirstChild("MPD-Radio") mdotModel = game.Workspace:FindFirstChild("MDOT-Radio") mdpsModel = game.Workspace:FindFirstChild("MDPS-Radio") function updateChannel1() connectedchannel = script.Parent.Frame.Network.CNetwork.Value Channel = game.Workspace:FindFirstChild(connectedchannel) if Channel == Channel1Model then GUI.Line1.Text = Channel.Line1.Value GUI.Line2.Text = Channel.Line2.Value GUI.Line3.Text = Channel.Line3.Value GUI.Line4.Text = Channel.Line4.Value GUI.Line5.Text = Channel.Line5.Value GUI.Line6.Text = Channel.Line6.Value GUI.Line7.Text = Channel.Line7.Value Tool.Value.Handle.Alert.Volume = 0.4 Tool.Value.Handle.Alert.Run.Value = true end end function updateChannel2() connectedchannel = script.Parent.Frame.Network.CNetwork.Value Channel = game.Workspace:FindFirstChild(connectedchannel) if Channel == Channel2Model then GUI.Line1.Text = Channel.Line1.Value GUI.Line2.Text = Channel.Line2.Value GUI.Line3.Text = Channel.Line3.Value GUI.Line4.Text = Channel.Line4.Value GUI.Line5.Text = Channel.Line5.Value GUI.Line6.Text = Channel.Line6.Value GUI.Line7.Text = Channel.Line7.Value Tool.Value.Handle.Alert.Volume = 0.4 Tool.Value.Handle.Alert.Run.Value = true end end function updateChannel3() connectedchannel = script.Parent.Frame.Network.CNetwork.Value Channel = game.Workspace:FindFirstChild(connectedchannel) if Channel == Channel3Model then GUI.Line1.Text = Channel.Line1.Value GUI.Line2.Text = Channel.Line2.Value GUI.Line3.Text = Channel.Line3.Value GUI.Line4.Text = Channel.Line4.Value GUI.Line5.Text = Channel.Line5.Value GUI.Line6.Text = Channel.Line6.Value GUI.Line7.Text = Channel.Line7.Value Tool.Value.Handle.Alert.Volume = 0.4 Tool.Value.Handle.Alert.Run.Value = true end end Channel1Model.Line7.Changed:connect(updateChannel1) Channel2Model.Line7.Changed:connect(updateChannel2) Channel3Model.Line7.Changed:connect(updateChannel3)