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

Local Script not firing server?

Asked by 6 years ago
-- LocalScript in StarterGui

local Lights = game.Workspace.ActualLights.Baseplate
local LightRemote = game.ReplicatedStorage.ChangeLightColor
local ClubColorRemote = game.ReplicatedStorage.ChangeClubColor





--local module = require(1040328849)     modules dont work in localscript so i extracted it

function parse(x,str)
local last=0
local tbl={}
for i=1,string.len(str) do
    if str:sub(i,i) == x then
        table.insert(tbl,str:sub(last,i -1))
        last=i +1
    elseif i == string.len(str) then
        table.insert(tbl,str:sub(last,i))
        last=i
    end
end
return(tbl) 
end



Admins = {"DigitalEntry","kylerzong"}
IsAdmin = false
for i,v in pairs(Admins) do
    if game.Players.LocalPlayer.Name:lower() == v:lower() then
        IsAdmin = true
    end
end

local debug = true

function dbprint(m) if debug == true then print("[DB] "..m) end end

if IsAdmin then
    game.Players.LocalPlayer.Chatted:connect(function(msg)
        local msgl = msg:lower()
        local args = parse(" ",msgl)
        local prefix = ";"
        local command = args[1]
        if command == (prefix.."color") then
            dbprint("color command rec")
            if args[2] == "lights" then
                dbprint("color command rec, lights rec")
                LightRemote:FireServer(args[3])
                dbprint("Server Fired")
            elseif args[2] == "club" then
                dbprint("color command rec, club rec")
                ClubColorRemote:FireServer(args[3])
                dbprint("Server Fired")
                dbprint("color command rec, club rec, color ->"..args[3])
            end
        elseif command == (prefix.."fix") then
            dbprint("fix command rec")
            if args[2] == "lights" then
                dbprint("fix command rec, lights rec")
                LightRemote:FireServer("fix")
            elseif args[2] == "club" then
                dbprint("fix command rec, club rec")
                ClubColorRemote:FireServer("fix")
            end
        end
    end)
end





-- Script in the model of "Lights"

local LightRemote = game.ReplicatedStorage.ChangeLightColor



LightRemote.OnServerEvent:connect(function(player, color)
    print("RAWRXD")
end)



-- Output

https://gyazo.com/4f3257d89343ebb5adf84a59894ac7ef


0
Where is the script located? *not local script* TheePBHST 154 — 6y
0
It's in a model in Workspace called ActualLights DigitalEntry 0 — 6y
0
Little more info on the script would be nice. RubenKan 3615 — 6y
0
On line 83, you’re using OnServerEvent, which is only used on server scripts. Simply change that to OnClientEvent and it should work. User#20279 0 — 6y
0
It's a custom command script. it's suppose to fire the server if it finds ;color lights or ;color club, when an admin types the command it prints the print statements but doesn't fire the server DigitalEntry 0 — 6y

Answer this question