Tool not cloning into StarterGear

Self-explanatory title, no errors, it just doesn’t clone into it for some reason. Any help would be greatly appreciated!

local MarketplaceService = game:GetService("MarketplaceService")
local button = script.Parent
local player = game.Players.LocalPlayer
local gamepassId = (TEST PASS ID HERE)
local ClickSound = script.Parent.ClickSound
local tool = game.ReplicatedStorage:WaitForChild("GravityCoil")

button.MouseButton1Click:connect(function()
	if player then
		ClickSound:Play()
		MarketplaceService:PromptGamePassPurchase(player, gamepassId)
		MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamepassId, wasPurchased)
			if wasPurchased then
				print("Purchase successful!")
				local ToolClone = tool:Clone()
				ToolClone.Parent = player:WaitForChild("StaterGear")
			end
		end)
	end
end)
1 Like

Is this a Script or a local script?

1 Like

Local script through a GUI button

1 Like

Try firing a remote event and then the script puts the tool into the StarterGear

2 Likes

Will give this a try, thanks

charsssss

1 Like

If u need the code:

Make a RemoteEvent in ReplicatedStorage call it Give
Make a Script in ServerScriptService call it whatever u want
Fire the server like this:

LOCAL SCRIPT: --this is inside ur GUI

local ToolName = "ToolNameHere"

local ReplicatedStorage= game:GetService("ReplicatedStorage")
ReplicatedStorage.Give:FireServer(ToolName)

SCRIPT: --this is inside ServerScriptService

local event = game:GetService("ReplicatedStorage").Give

event.OnServerEvent:Connect(function(plr, toolname)
	if game.ReplicatedStorage:FindFirstChild(toolname) then
		local clone = game.ReplicatedStorage[toolname]:Clone()
		clone.Parent = plr.StarterGear
	else
		warn("No tool found called:",toolname)
	end
end)
2 Likes

I’ll mark this as the solution instead of the last reply so other people see this

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.