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

Tool Giving GUI gives tool to players Backpack on studio but not online roblox server why?

this script is supposed to give a Tool named Buso from Lighting into your backpack it works when i test on studio but when i play from roblox server it does not work..

game is not filtering enabled..

script.Parent.MouseButton1Click:connect(function()
		local Player = script.Parent.Parent.Parent.Parent
		if Player then
		if game.ServerStorage:FindFirstChild(Player.Name).MeleeLevel.Value >= 100 then
			local Buso = game.Lighting.Buso:Clone()
			Buso.Parent = Player.Backpack
			script.Parent.Parent:Remove()
		end
	end
end)

1 comment

0

Sorry the codinggot rearranged for some strange reason... But in roblox its tabbed correctly.

1 answer

✓ Accepted answer

The only problem is that, FE or not, ServerStorage cannot be accessed by the client. There are also some other things you can improve on.

I am assuming you are using a LocalScript, as that is what is practical.

-- I am making all of these variables for organisation and optimisation
local p = game.Players.LocalPlayer -- Only works on the client
local button = script.Parent
local gui = button.Parent
local meleeLevel = p:WaitForChild("Data"):WaitForChild("MeleeLevel") -- p.Data.MeleeLevel, this is my recommended setup, just because it's what I believe to be tidier. You can do whatever, though.
local backpack = p.Backpack
local tool = game.ReplicatedStorage:WaitForChild("Buso") -- Use ReplicatedStorage, because it can be accessed by the client

button.MouseButton1Click:connect(function()
	if meleeLevel.Value >= 100 then
		local nTool = tool:Clone()
		nTool.Parent = backpack
		gui:Destroy() -- Remove is deprecated, use Destroy
	end
end)

Also, the reason your code worked on the server was because Play Solo runs everything on the client.


Hope I helped!

~TDP

4 comments

0

Thing is stats get saved to ServerStorage and i have other scripts that revolve around the stats saved in ServerStorage

0

You can change it, and it is a big problem that will need to be fixed either way. Also, what I meant to say was that you also should store things like tools etc. in Rep. Storage and Server Storage.

0

If i were to change it to a dialog script instead of a GUI would i be able to access ServerStorage for my stats?

0

Yes, but only if you change it to a ServerScript. Use the wiki article for DialogChoiceSelected to get the player.

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