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

ServerScriptService is not a valid member of DataModel?

Guys this problem is driving me crazy!

I always get this error when I'm trying to get the ServerScriptService from a LocalScript.

RemoveEvent is in ServerScriptService

Here's the code: It's a LocalScript

script.Parent.MouseButton1Click:connect(function()
	local player = game.Players.LocalPlayer
	local ThePlayerName = script.Parent.Parent:WaitForChild("PlayerNameHere").Text
	game.ServerScriptService:WaitForChild("UnBanPlayer"):FireServer(ThePlayerName)
	print(ThePlayerName.."'s the player name that got sent!")
end)

When I use a LocalScript it gives me that error. But when I use a ServerScript I get the following error:

FireServer can only be called from Client.

What do I do?

I'm getting confused!

1 answer

✓ Accepted answer

I think ServerScriptService can only be accessed by server scripts, which is why you’re getting errors from a localscript.

When you switch to a server script though, you’ll still get an error because :FireServer() in line 4 can only be used by local scripts. Server scripts do :FireClient() or :FireAllClients() and local scripts do :FireServer().

Oh, and when you play the game in a server, your script won’t work anyways because I think only local scripts can be used for GUI buttons. (If it’s in a SurfaceGui though, I don’t know. I haven’t used SurfaceGuis often.)

Hoped this helped!

1 comment

0

I did a ton of changings and followed ur tips and made it all on the workspace using remote events and everything is working! I've been trying so long! Hallelujah i'm free. Thank you my friend!

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