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

[FE] made a radio it works in studio but not in online mode?

Asked by
RootEntry 111
5 years ago

Hello, I am trying to make a Radio for a game. I made it FE compatible by adding Remote Events, server scripts and of course client scripts.

It works by when you click T it changes to Active or Inactive. Then when it's active you can type in the radio but not if it's inactive.

Everything works just fine in studio, but when I and my friend try it in online mode it dosen't wanna switch mode, not even in the Client.

Client Side Scripts:

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.T then
        game:GetService("ReplicatedStorage").RadioEvents.changeStatus:FireServer()
    end
end)
--// iiLevelMaker
local player = game.Players.LocalPlayer

player.Chatted:Connect(function(msg)
    game:GetService("ReplicatedStorage").RadioEvents.updateRadio:FireServer(msg)
end)
--// iiLevelMaker
local player = game.Players.LocalPlayer
local Channel = workspace.RadioSystem

function Update()
    game:GetService("ReplicatedStorage").RadioEvents.updateScript:FireServer()
end

Channel.Line9.Changed:Connect(Update)
wait(0.2)
Update()

Server Side Scripts

game:GetService("ReplicatedStorage").RadioEvents.changeStatus.OnServerEvent:Connect(function(Player)
    local label = Player:WaitForChild("PlayerGui"):WaitForChild("Radio").Status
    local on = Player:WaitForChild("PlayerGui"):WaitForChild("Radio").On

    if (on.Value == false) then
        on.Value = true
        label.Text = "Active. T"
        label.TextColor3 = Color3.new(85/255, 170/255, 127/255)
    elseif (on.Value == true) then
        on.Value = false
        label.Text = "Inactive. T"
        label.TextColor3 = Color3.new(255/255, 58/255, 58/255)
    end
end)
game:GetService("ReplicatedStorage").RadioEvents.updateRadio.OnServerEvent:Connect(function(Player, msg)
    local label = Player:WaitForChild("PlayerGui"):WaitForChild("Radio").Status
    local on = Player:WaitForChild("PlayerGui"):WaitForChild("Radio").On
    local Channel = workspace.RadioSystem

    if not (on.Value == false) then
        Channel.Line1.Value = Channel.Line2.Value
        Channel.Line2.Value = Channel.Line3.Value
        Channel.Line3.Value = Channel.Line4.Value
        Channel.Line4.Value = Channel.Line5.Value
        Channel.Line5.Value = Channel.Line6.Value
        Channel.Line6.Value = Channel.Line7.Value
        Channel.Line7.Value = Channel.Line8.Value
        Channel.Line8.Value = Channel.Line9.Value
        Channel.Line9.Value = Player.Name.." ("..Player:WaitForChild("Data").CallSign.Value.."): "..msg
    end
end)
game:GetService("ReplicatedStorage").RadioEvents.updateScript.OnServerEvent:Connect(function(Player)
    local label = Player:WaitForChild("PlayerGui"):WaitForChild("Radio").Status
    local gui = Player:WaitForChild("PlayerGui"):WaitForChild("Radio").Frame
    local on = Player:WaitForChild("PlayerGui"):WaitForChild("Radio").On
    local Channel = workspace.RadioSystem

    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
    gui.Line8.Text = Channel.Line8.Value
    gui.Line9.Text = Channel.Line9.Value
end)

And I have a model in workspace called RadioSystem with 9 string values.

0
Ew, why is the server modifying the PlayerGui? It should NOT be doing that. Heck that might be the reason why it won't work. User#19524 175 — 5y
0
I have made it so it's client side and I kept the one that changes the value so it actually changes for the whole server. It still dosen't work. RootEntry 111 — 5y
0
You can't access the PlayerGui using the server, that's why it doesn't work. Also I have to say that the script is poorly made ... sorry Axdrei 107 — 5y

Answer this question