Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can a local script access objects from the replicated and server storage?

Asked by 5 years ago

I have a script in a GUI that locates an object in the server storage. It couldn't find it so I placed the object in the replicated storage and redid everything. Still couldn't find the object. Can a local script access objects from the replicated and server storage?

1script.Parent.MouseButton1Click:Connect(function()
2 
3    local Money = script.Parent.Parent.Parent.Parent.Parent.Parent.leaderstats["Fish Flakes"].Value
4 
5    if Money >= game:GetService("ReplicatedStorage").Skins.DefaultFish.Cost.Value then
6        script.Parent.Owned = true 
7    end
8 
9end)

2 answers

Log in to vote
1
Answered by 5 years ago

Like Code1400 said, use a remote event. Keep your LocalScript in your GUI, but insert a regular Script into ServerScriptService. Also insert a RemoteEvent into ReplicatedStorage. Place your object wherever you want because the server can access it anywhere. By the way, make sure your LocalScript is under your ImageButton/TextButton, not the ScreenGui. Now this is what I suggest you have in your scripts:

Local Script

1script.Parent.MouseButton1Click:Connect(function()
2    game.ReplicatedStorage.RemoteEvent:FireServer()
3end)

Script

1game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
2local Money = script.Parent.Parent.Parent.Parent.Parent.Parent.leaderstats["Fish Flakes"].Value
3    if Money >= game:GetService("ReplicatedStorage").Skins.DefaultFish.Cost.Value then
4            script.Parent.Owned = true 
5    end
6end)

Hope this helps!

Ad
Log in to vote
1
Answered by 5 years ago

im not sure if they can see anything server sided you have to test that out, but the client can not change any value in the server or they will be kicked from the game. use remote events and functions to do what you want

Answer this question