Want to stay connected to the Scripting Helpers community and get real-time help? Join the Scripting Helpers Discord Server!
Ad
Log in to vote
0

ServerScriptService is not a valid member of DataModel?

Asked by 3 months ago

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

Log in to vote
0
Answered by
Denny9876 942
3 months ago

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!

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! wilsonsilva007 202 — 3mo
Ad

Answer this question