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 4 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?

script.Parent.MouseButton1Click:Connect(function()

    local Money = script.Parent.Parent.Parent.Parent.Parent.Parent.leaderstats["Fish Flakes"].Value

    if Money >= game:GetService("ReplicatedStorage").Skins.DefaultFish.Cost.Value then
        script.Parent.Owned = true  
    end

end)

2 answers

Log in to vote
1
Answered by 4 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

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

Script

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

Hope this helps!

Ad
Log in to vote
1
Answered by 4 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