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)
-- 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)
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)
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.