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

Why isn't the serverscript responding to the remote Event?

Asked by 8 years ago

I am trying to make a gui which should load something into the workspace. the maps are in the replicated storage and the remove event is also in replicated storage.

the two scripts (clientHandler and serverHandler) are placed in a gui btn in StarterGui

here are the scripts Client Handler

    loadWep = game:GetService('ReplicatedStorage').client_server_Bridge.loadWep
        script.Parent.MouseButton1Click:connect(function()
    loadWep:FireServer()
    print('fired!')
    end)

Server Handler

    loadWep = game:GetService('ReplicatedStorage').client_server_Bridge.loadMap
DM = game.Workspace.DataModel
MapHolder = DM.MapHolder
w = game.Workspace._W
w1 = game.Workspace._W1
mapName = script.Parent.Name


function searchMap(name, loc)
    for k,v in pairs(loc) do
        if v.Name == name then
            return v
        end
    end
end

function onClick()
        local EmptySpace = MapHolder:GetChildren()
            if #EmptySpace >= 1 then
                MapHolder:ClearAllChildren()
            end
        searchMap(mapName, game.ReplicatedStorage.Maps:GetChildren()):clone().Parent = MapHolder
        w.Transparency = 0.6
        w1.Transparency = 0.6
end

loadWep.OnServerEvent:connect(function()
    onClick()
end)

Please help me

0
Your server script shouldn't be in the player. Try puting it in serverScriptService. GoldenPhysics 474 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Scripts either don't, or under any circumstances shouldn't run under the PlayerGui when FilteringEnabled is active.

You'll need to move your script to ServerScriptService as was suggested. On a side note, your searchMap function is redundant:

loadWep = game:GetService('ReplicatedStorage').client_server_Bridge.loadMap
DM = game.Workspace.DataModel
MapHolder = DM.MapHolder
w = game.Workspace._W
w1 = game.Workspace._W1
mapName = script.Parent.Name

function onClick()
        local EmptySpace = MapHolder:GetChildren()
            if #EmptySpace >= 1 then
                MapHolder:ClearAllChildren()
            end
        game.ReplicatedStorage.Maps:FindFirstChild(mapName):Clone().Parent = MapHolder
        w.Transparency = 0.6
        w1.Transparency = 0.6
end

loadWep.OnServerEvent:connect(onClick)
0
what do you mean reundant? buoyantair 123 — 8y
0
I mean it's unnecessary, as FindFirstChild does exactly the same thing but with better performance because it's done through C User#6546 35 — 8y
Ad

Answer this question