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