Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

Your server script shouldn't be in the player. Try puting it in serverScriptService.

1 answer

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)

2 comments

0

what do you mean reundant?

0

I mean it's unnecessary, as FindFirstChild does exactly the same thing but with better performance because it's done through C

This discussion is preserved as it was. New answers, comments, and votes are closed.