What is wrong with this tool purchase script?

I have a shop in my game that is supposed to take away shells from the player if they have enough and put a tool in their backpack but the part that puts it in their backpack is not working. Here’s the script:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	if player.leaderstats.Shells.Value >= 50 then
		-- Checks if player has enough shells
		game.Workspace.PurchaseSuccessful:Play()
		game.ReplicatedStorage.PurchaseBucket:FireServer(50)
		-- Fires RemoteEvent that charges player
		game.ServerStorage.BucketTool.Parent = game.Players.LocalPlayer.Backpack
	else
		game.Workspace.PurchaseFailed:Play()
		script.Parent.Text = ("Insufficient funds!")
		wait(3)
		script.Parent.Text = ("Purchase for 50 Shells...")
	end
end)

The script is a LocalScript inside of the purchase button and I have a bucket tool inside of ServerStorage.

Hmm, looks as if it is server sided, try to look in the PurchaseBucket Remote. That is where the problem most likely is

the purchase bucket remote just charges the player and thats working fine but ill look into that

I changed the local script to this but now I don’t think its working at all:

local player = game.Players.LocalPlayer
local BucketTool = game.ServerStorage.BucketTool

script.Parent.MouseButton1Click:Connect(function()
	if player.leaderstats.Shells.Value >= 50 then
		-- Checks if player has enough shells
		game.Workspace.PurchaseSuccessful:Play()
		game.ReplicatedStorage.PurchaseBucket:FireServer(50)
		-- Fires RemoteEvent that charges player
		BucketTool.Parent = player.Backpack
	else
		game.Workspace.PurchaseFailed:Play()
		script.Parent.Text = ("Insufficient funds!")
		wait(3)
		script.Parent.Text = ("Purchase for 50 Shells...")
	end
end)

I was able to fix this by myself actually

2 Likes

Are you able to post the solution you did? The developer forum is used for finding solutions to problems, and others may find this post and not know what to do.

2 Likes

Here’s the script that worked for me:

local player = game.Players.LocalPlayer
local Bucket = game.ReplicatedStorage.Bucket:Clone()

script.Parent.MouseButton1Click:Connect(function()
	if player.leaderstats.Shells.Value >= 50 then
		-- Checks if player has enough shells
		game.Workspace.PurchaseSuccessful:Play()
		game.ReplicatedStorage.PurchaseBucket:FireServer(50)
		-- Fires RemoteEvent that charges player
		Bucket.Parent = player.Backpack
	else
		game.Workspace.PurchaseFailed:Play()
		script.Parent.Text = ("Insufficient funds!")
		wait(3)
		script.Parent.Text = ("Purchase for 50 Shells...")
	end
end)

Put the bucket in replicatedstorage, not serverstorage.

2 Likes