Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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!

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

This discussion is preserved as it was. New answers, comments, and votes are closed.