Tool in Replicated Storage going invisible

It might be a bit easier for us to help if you could post a code sample. Thanks!

2 Likes

LocalScript seems unsafe, because those scripts will be tampered by exploiters eventually. Proper FE scripting is required for the cloning, if the tool needs to be seen client-sided.

Make sure the script is not placed in ReplicatedStorage. Because they won’t run and will never run there.

Consider using an ordinary script and clone it from ServerStorage. Because ReplicatedStorage will stress the network if you try to do it from there.

If you’re still considering the local script, post your code here. I believe it is an error within.(also test the tool again by re-equipping it)

You’re only cloning it locally which causes it to break. You need to clone the tool with a server script instead.

1 Like

What do you mean by this? Scripts in-game are RobloxLocked which means they cannot be viewed or modified by users who intend to do so (unless it uses loadstring, which is a different story). These scripts cannot be tampered, otherwise there would be chaos.

What? The cloning and parenting of a tool is a very very minor addition to the network load. If you do it through ReplicatedStorage using a LocalScript, that load is on the client. If you do it with a server script and clone the tool through ServerStorage, that load will be on the server.

In the future when making statements like these please back them up with proof or a credible source and ensure they are factual.

1 Like

Also, I have been using LocalScript of the shop for a month already, this is the first time it happened, here is the local script by the way.

local leaderboard = player:WaitForChild("leaderstats")
local button = script.Parent
local price = button:WaitForChild("Price")
local item = button:WaitForChild("ItemName")
local rs = game:GetService("ReplicatedStorage")

button.MouseButton1Click:connect(function()
	if leaderboard.Cash.Value >= price.Value then 
		leaderboard.Cash.Value = leaderboard.Cash.Value - price.Value
		local item = rs.Shop:WaitForChild(item.Value)
		item:Clone().Parent = player.Backpack
	elseif leaderboard.Cash.Value < price.Value then
		button.Text = "Not enough cash"
		wait(5)
		button.Text = price.Value.."$"
	end
	
end)

Also, I would like to know how is cloning locally cause it to break? Other items work, this is the first one that didn’t work.

if leaderboard.Cash.Value >= price.Value then

This is very poor practice because you are trusting the client to make a decision on whether or not the client itself has enough money to buy something. This if statement is essentially locking a door and leaving the key there for anyone to open. All an exploiter has to do is run the following line of code in their exploit:

game.Players.LocalPlayer.leaderstats.Cash.Value = 99999999

They now have 99999999 cash, and because you have a LocalScript checking if they have enough cash, of course they do!

Any changes an exploiter makes (such as editting a leaderboard to give themselves money) are client sided, and so the server and all other players do not see that change happen. That change is solely visible on the exploiters screen. In order to prevent abuse of this, you should handle ALL calculations and checks of whether or not the player can do something on the server. This way, if a player does exploit and give themselves the cash needed to buy something, that change is not visible to the server, the server only sees cash that was legitimately awarded by the game, and so the server declines the player’s request to buy the item. On top of this, do not store the prices of items client-side, as the client can modify an item to cost whatever they want, even 0 Cash! A better way of doing this could be to create a folder in ServerStorage called ‘ShopItems’. Inside this folder would be another Folder with the item name, and inside that folder you would have an IntValue called ‘Price’, with its value set to the price that you want the item to have. For example:

Screenshot_20190205-082735_Chrome

You can do this verification to see if a player can buy something through RemoteFunctions.

Client

local leaderboard = player:WaitForChild("leaderstats")
local button = script.Parent
local item = button:WaitForChild("ItemName")
local rs = game:GetService("ReplicatedStorage")
local VerifyPurchase = rs:WaitForChild("VerifyPurchase")

button.MouseButton1Click:connect(function()
    local CanPurchaseTool = VerifyPurchase:InvokeServer(item)
    if CanPurchaseTool then
        -- Change the GUI to say they bought it
    else
	button.Text = "Not enough cash"
	wait(5)
	button.Text = price.Value.."$"
    end	
end)

Server

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local ShopItems = ServerStorage:WaitForChild("ShopItems")

local VerifyPurchase = Instance.new("RemoteFunction")
VerifyPurchase.Parent = ReplicatedStorage
VerifyPurchase.Name = "VerifyPurchase"
 
VerifyPurchase.OnServerInvoke(function(Player, ItemToBuy)

    print(player.Name.." wants to purchase "..ItemToBuy)
    local ItemPrice = ShopItems:FindFirstChild(ItemToBuy) -- ItemToBuy would be a string
    if ItemPrice then
        local leaderstats = Player:FindFirstChild("leaderstats")
        if leaderstats then
            if leaderstats.Cash.Value >= ItemPrice then -- Check if they have enough cash
                local Tool = ServerStorage:FindFirstChild(ItemToBuy):Clone()
                Tool.Parent = Player.Character
                return true -- Tell them they can buy it
            else
                return false -- Tell them they can't buy it
            end
        end
    else
        return false
    end
end)

I wrote this on mobile so apologies if there’s any mistakes. You can learn more about RemoteFunctions here.

1 Like

So in conclusion the item is going invisible because of the cloning is happening on the local script?

1 Like

Above is unrelated but something you should definitely consider because it will help you with security.

On the topic of your question, does it go invisible for you when you buy it, or does it go invisible on your screen if someone else buys it?

1 Like

It goes invisible for me when I buy it but I don’t know about others.

1 Like

Have you checked F9 to see if there’s any errors? Have you tried cloning the tool server side? It’s most likely happening because you’re cloning it client side.

I tried with other tools and it works, but when it comes to this umbrella tool, it doesn’t work.

I can’t really help you unless you either give me a file to reproduce this, or diagnose it and give me any errors you see from F9.

Thank you for all the support guys! I have found the problem, the problem was with the Massless property being true. Don’t know why, but when I disabled Massless property, my umbrella works.

I strongly doubt this was the proper solution to your problem. Try re-evaluating your code to see what might’ve really caused this problem.

Woops, forgot to mention it was client-sided stress. :slight_smile:

Gotta eat all that scripting knowledge!

When I changed other tools in the shop’s parts to massless property, it also happened. But I also doubt it is a proper solution, it is temporary fix for now.

I’ve got a number of tools in my game with parts set to massless, they work fine. I’m glad you figured it out, that’s some strange behavior going on.

The tools I have all uses meshes in the part. The problem might be Massless+Mesh, that might do something, you guys try to replicate and see. It happened to me, either a bug or strange behavior.

It would help if you attached a file to reproduce the error with the tool.