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?
1 | script.Parent.MouseButton 1 Click: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 |
9 | end ) |
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
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | game.ReplicatedStorage.RemoteEvent:FireServer() |
3 | end ) |
Script
1 | game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect( function () |
2 | local 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 |
6 | end ) |
Hope this helps!
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