Hello developers, So I made a post asking how I would make a script disable and reenable when you click on a tool, This is kind of like the same thing except its with a button and a mps.
local plr= game.Players.LocalPlayer
local mps= game:GetService("MarketplaceService")
local id= 1153678368
script.Parent.MouseButton1Click:Connect(function()
game.ServerScriptService.shop.Disabled = false
mps:PromptProductPurchase(plr, id)
wait(2.5)
game.ServerScriptService.shop.Disabled = true
end)
Sorry I feel like I just posted a topic about this lol.
If You Go and Play the Game,
The Scripts In Server Scripts Service Just Vanish Or Something. I Have no Idea.
Suppose, You Have A Script Called “Handler” in ServScriptServ. When You go And Play, If You Search for “Handler” in the Server Search Bar, Nothing will Appear.
What kind of Script is it? Like what does the Script Your Referring to Do?
I Think You Will need To Change the Scripts Location Accordingly.
The reason stuff in ServerScriptService and ServerStorage disappear is because it is not replicated to the client. If you do not know, there are some services where only the server can see stuff and only clients can see stuff.
ServerScriptService and ServerStorage are examples of where only the server can see the instances
PlayerScripts is an example of only the client can see
The reason you cant see them anymore is that Server Script Service is handled on the server, while your playing, you can only see whats available locally on the client side. While you are testing your game, you can swap between Client and server by selecting the option labeled Current: Client or Current : Server under the Test tab.
I’m going to assume that since you are identifying the plr with LocalPlayer that this is running in a local script. In that case, a local script wont be able to see Server Script Service because Server Script Service is stored on the server and local scripts are only usable on the client side of the game.
Now as other people who replied we’re saying, scripts inside ServerScriptService can only be accessed on the server side.
You’re not out of luck, you could use RemoteEvents to basically talk to the server from the client and the server will handle the request the way the handler on the server is setup.
Here’s a little example
local remote = game.ReplicatedStorage:WaitForChild(“MyRemoteEvent”)
local plr= game.Players.LocalPlayer
local mps= game:GetService("MarketplaceService")
local id= 1153678368
script.Parent.MouseButton1Click:Connect(function()
remote:FireServer("turn off shop script")
mps:PromptProductPurchase(plr, id)
wait(2.5)
remote:FireServer("turn on shop script")
end)
Then on the server
local remote = game.ReplicatedStorage.MyRemoteEvent
local shopScript = game.ServerScriptService.shop
remote.OnServerEvent:Connect(function(msg)
if msg == "turn off shop script" then
shopScript.Disabled = true
elseif msg == "turn on shop script" then
shopScript.Disabled = false
end
end)