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

Please Help Me With Cloning Item From Store With Filtering Enabled?

Okay So basically heres the deal. I have a system that when you push a button you get an ite from the store if you have enough money.

Right now I have the Tools located in ReplicatedStorage. I basically want the gun to clone from replicated storage to the players backpack when you push the button. It was working fine with FE off but not with it on.

This particular script is one of the buttons pushed to clone the tool if you have enough money (basically buy a gun from the store). So when you push this button it clones the gun fro replicated storage into th players BackPack (but as I stated below, not working with FE On). Please iff you have any questions ask them as I need help with this. Thanks in advance.

local SaveToDataStore = game.ReplicatedStorage.SaveToDataStore
local player = game.Players.LocalPlayer
local money = player.leaderstats.Money

for _, button in pairs(script.Parent:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseButton1Click:Connect(function()
			if money.Value >= button.Cost.Value then
				money.Value = money.Value - button.Cost.Value
				
				game.ReplicatedStorage.Guns["Glock 32"]:Clone().Parent = player.StarterGear
				game.ReplicatedStorage.Guns["Glock 32"]:Clone().Parent = player.Backpack
				
				SaveToDataStore:FireServer(money.Value)
			end
		end)
	end
end

PLEASE HELP ME WITH THIS. I AM NEARLY FINISHED MY GAME AND AM STUCK RIGHT NOW.

1 answer

You're already using a RemoteEvent, so you just have to make another. Simply create a server script that will clone the item fired by the local script and parent it to the parent specified by the local script. Here's an example:

Server script:

local cloneEvent = game:GetService("ReplicatedStorage"):WaitForChild("CloneEvent")

cloneEvent.OnServerEvent:connect(function(player, item, parent)
     local clone = item:Clone()
           clone.Parent = parent
end)

Local script:

local cloneEvent = game:GetService("ReplicatedStorage"):WaitForChild("CloneEvent")

cloneEvent:FireServer(glock32, player.Backpack) -- These are not accurate, you need to change the values.

And that should work fine.

1 comment

0

what do u mean when you say -- These are not accurate you need to change the values? What do I change them too?

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