I was trying to make a gravity coil that got added to your players backpack if you purchase it. It adds the item to my players backpack, but the script that makes the gravity coil work breaks. I think this is because I need to call on all of the children of the gravity coil tool but i’m not sure how. Can anyone help me?
local player = game.Players.LocalPlayer
local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,11056094)
if ownsGamepass then
local GravityCoil = game:GetService("ReplicatedStorage"):WaitForChild("GravityCoil"):Clone()
GravityCoil.Parent = player.Backpack
end
game.Players.PlayerAdded:Connect(function(Player)
local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,11056094)
Player.CharacterAdded:Connect(function()
if ownsGamepass then
local GravityCoil = game:GetService("ReplicatedStorage"):WaitForChild("GravityCoil"):Clone()
GravityCoil.Parent = player.Backpack
end
end)
end)
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassID = ______ -- The Gamepass ID
game.Players.PlayerAdded:Connect(function(player)
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then
game.ServerStorage.GravityCoil:Clone().Parent = player:WaitForChild("Backpack")
game.ServerStorage.GravityCoil:Clone().Parent = player:WaitForChild("StarterGear")
end
end)
You can even use this script. (Note: Add this script in workspace)
Put the tool in “server storage” and use this script.