Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Tool not functioning at all when given from gui? [closed]

Asked by 3 years ago

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
E that you have the same question here... https://scriptinghelpers.org/questions/114423 LinavolicaDev 570 — 3y

Marked as Duplicate by SteelMettle1, matiss112233, nekosiwifi, and DeceptiveCaster

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
3
Answered by 3 years ago

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 Backpackshares 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.

Ad