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

Tool not functioning at all when given from gui?

I have made a textbutton GUI to give a player a tool into their backpack. The tool is given but does not work, I placed it in the starter pack and it functions works well. There are no errors or mistakes in the script. It just does not work

I think it has something to do with filtering enabled...

Script:

local used = false
local desuboru = game.ReplicatedStorage.Attacks.Desuboru

script.Parent.MouseButton1Click:Connect(function()
	if used == false then
		local clone = desuboru:Clone()
		clone.Parent = game.Players.LocalPlayer.Backpack
		used = true
	else
		script.Parent.Text = "Equipped"
		wait(1)
		script.Parent.Text = "Equip"
	end
end)

Please help!

1 comment

1

E that you have the same question here... https://scriptinghelpers.org/questions/114423

1 answer

✓ Accepted answer

You're right it has to do with filtering enabled and some built-in security that Roblox has. If a client (local script) creates a tool, that tool is destroyed pretty quickly if it is equipped. I wasn't aware that parenting it to the backpack also has some security behind it as well.

To understand this, we need to understand what is actually happening behind the scenes. The player's Backpack shares a lot of the same traits with ReplicatedStorage: objects inside only replicate in one direction (from server to client, not client to server). But something else happens with the Backpack: How do you prevent an exploiter from constantly attempting to equip an inappropriate tool? Consider this: exploiter constantly tries to equip an ill-conceived tool; how do you stop this? Use a check on the server to see if the tool exists from its perspective?

Unfortunately, this won't work because the tools are replicated to all other clients immediately. What you'll end up with are flashes of the inappropriate tool...not cool. So Roblox did something good: destroy all tools that are created and then equipped from the client. I don't mean ignore the tool, I truly do mean :Destroy()! I ran into this problem before when I noticed the engine pancaking my tools.

To get around this, just send requests from the client as a remote, verify if the request can be fulfilled/is accurate on the server, then process the request on the server.

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