ServerScriptService is not a valid member of the DataModel "Game"

Ok, so this is really annoying, i have this script inside of a local script and im trying require a module script name “Abilities”. Whenever i play the game it gives me an error saying that serverscriptservice is not a valid member of the datamodel “Game”. Idk what to do.

local selectButton = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
**local Abilities = require(game.ServerScriptService.Abilities)**
local TeleportService = game:GetService("TeleportService")
local teleportOptions = Instance.new("TeleportOptions")




repeat wait() until script.Parent.Text ~= "Button"



selectButton.MouseButton1Click:Connect(function()
	if selectButton.Text == "Play" then
		Abilities:saveData(player)
		
		TeleportService:Teleport(8657574891, player)
	end
end)
1 Like

You can’t utilize ServerScriptService in a LocalScript.

You can’t access ServerScriptService through a localscript.

Edit: he beat me to it

3 Likes

How would I convert that entire thing into a server script, especially with the gui button and stuff.

You would have to use Remote Functions and Events for the client and server to communicate:

-- Example (Client Side)

local selectButton = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local TeleportService = game:GetService("TeleportService")
local teleportOptions = Instance.new("TeleportOptions")
local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
-- The RemoteEvent to save their data

repeat wait() until script.Parent.Text ~= "Button"

selectButton.MouseButton1Click:Connect(function()
	if selectButton.Text == "Play" then
        remote:FireServer() -- Send a request to the server
		TeleportService:Teleport(8657574891, player)
	end
end)
-- Example (Server Side)

RemoteEvent.OnServerEvent:Connect(function(player)
    -- Connect a function to the RemoteEvent's signal
    -- The Player (or client) who fired the RemoteEvent is automatically passed as the first argument
    Abilities:saveData(player)
end)
1 Like

You’ll need a LocalScript to pick up the client input on the GUI, and you’ll have to fire a RemoteEvent while a server-side script is listening.

Ok. That seemed to have solved that problem but now its saying attempt to Index nil with “Abilities”

What does your ServerScript look like?

Screenshot 2022-06-27 142528
sorry its not very organized

I mean the actual code inside of the script

oh ok

local Abilities = require(game.ServerScriptService.Abilities)

game.ReplicatedStorage.AbilityRemote.OnServerEvent:Connect(function(player)
	Abilities:saveData(player)
end)

Try:

local Abilities = require(game:GetService("ServerScriptService").Abilities)

game.ReplicatedStorage.AbilityRemote.OnServerEvent:Connect(function(player)
	Abilities:saveData(player)
end)

If that doesn’t work, then try moving Abilities to ServerStorage and do

local Abilities = require(game:GetService("ServerStorage").Abilities)

game.ReplicatedStorage.AbilityRemote.OnServerEvent:Connect(function(player)
	Abilities:saveData(player)
end)

neither worked, i got the same message

What does your LocalScript look like?

local selectButton = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local TeleportService = game:GetService("TeleportService")
local teleportOptions = Instance.new("TeleportOptions")
local remote = game:GetService("ReplicatedStorage"):WaitForChild("AbilityRemote")
-- The RemoteEvent to save their data

repeat wait() until script.Parent.Text ~= "Button"

selectButton.MouseButton1Click:Connect(function()
	if selectButton.Text == "Play" then
		remote:FireServer() -- Send a request to the server
		TeleportService:Teleport(8657574891, player)
	end
end)

I’m not sure what could be causing your issue. For whatever reason, ServerScriptService doesn’t exist on your end

thats because its not called clientscriptservice for a reason

It’s because the client can’t access ServerScriptService. Just how it’s designed. If you want to run something on the server from the client, you’ll need to fire a RemoteEvent from the client while the server is listening.

I’m aware of that, the OP’s problem is that they can’t access it from a ServerScript.

Why not just put the module under that server script and access it from there easier?

or just put the module inside a folder under server script service.

i would not recommend putting important module in replicated storage - simply because it is exploitable.

have not read the whole thing yet, but i noticed that message

1 Like