Tool doesn't work when it is in Repllicated storage

Use the code @SOTR654 provided, that will fix your issue. It’s a few posts up.

game.Players.PlayerAdded:Connect(function(player)
	local Success, Has = pcall(function()
		return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 19237750)
	end)

	if Success and Has then
		local frozenStick = game:GetService("ServerStorage"):WaitForChild("FrozenStick"):Clone()
		frozenStick.Parent = player.Backpack
	end
end)
2 Likes

Solution without intention? :rofl:

1 Like

Can you please explain me what this means? Thank you.

A pcall() is used to check if the given function works, Success will return true or false depending on whether an error does not jump and can return something, if an error occurs, it will say the error, if not it will return true or false if the player has the game pass.

local Success, Number = pcall(function()
    return "number " + 4
end)
print(Success, Number) -- False, attempt to perform arithmetic (add) on string and number

local Success, Number = pcall(function()
    return "number " .. 4
end)
print(Success, Number) -- true, "number 4"
1 Like

Thank you for the solution. :grinning:
Also, Thank you @k_as for replying, and trying to help me.

Emm… You’re welcome to help :smile:
I didn’t really understand, I thought the problem was the tool script.

1 Like

You’re welcome! Don’t forget to mark as solution.

Yeah I would feel bad claiming a solution even though you said it before (even without realizing that was the issue).

What made me believe that it was a LocalScript was the “local player = game.Players.LocalPlayer” + the fact that the tool didn’t show up on my side but did on his side. This pretty much only happens when a LocalScript tries to get a tool, but the server doesn’t know that he has that tool thus creating the illusion that he was wielding one. Pretty much only exploiters do this.

1 Like

If the script of a tool is local, it will continue to work regardless of whether it is cloned by the client or the server, whereas a script from the server will not work if it is cloned by a client.

(Looking at the problem again, I don’t know why I thought the tool script was local)

Yeahh, the tool was fine, but he was giving the tool and checking for the gamepass on the client, which creates some very weird problems!

Easily solved, but very easy to forget about, especially if you’re just starting out.

Yes, the most obvious things almost always go unnoticed or ignored without knowing it, I should improve my reading comprehension.

Tools… don’t work in ReplicatedStorage? They only work when placed in a player’s Backpack or when placed in the StarterPack.

Took me a while to figure out too don’t worry, I also automatically assumed his giving script was server sided.

Read the entirety of this page please, every party involved understood this.

Hi, I tested it out, but when you reset, the tool gets gone, is there a solution to this problem? Thanks.