local player = script.Parent.Parent.Parent.Parent.Parent
local findTool = player:WaitForChild("BackPack"):FindFirstChild("AK-101")
script.Parent.MouseButton1Click:Connect(function(click)
if player.leaderstats.Cash.Value >= 100 then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 100
game.ReplicatedStorage.Tools["AK-101"]:Clone().Parent = player:WaitForChild("Backpack")
elseif findTool then
end
end)
and it’s suppost to copy a tool into my backpack but if i already own it then it shouldn’t do that. but even when i don’t have it, it still doesn’t copy it into my backpack, why?
Is this a local script? If so you should do player = game.Players.LocalPlayer
Also, it’s finding in by the tool after it gives it since you’re doing wait for child. You should do find first child. — misread the findfirstchild
Oh, you should be using local script and a remote event. The click isn’t working since it’s a server script. All you have to do is fire the server with the data and find the data using a server script. The documentation makes remote events easy to understand!
They’re pretty easy. It’s just sending data and waiting for the data. In a local script just RemoteEvent:FireServer(-data-) then on server script
You just do RemoteEvent:OnServerEvent:Connect(function(plr,-data-) end)
local playerowned = player["StarterPack"]
if playerowned:FindFirstChild["Your Tool Name"] then
print("Player Does have tools")
else
print("Player Doesnt have tools")
end
if its doesnt work its prob script error
edit : try this
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Tools = ReplicatedStorage["Tools"]["AK-101"]
local Price = 100
script.Parent.MouseButton1Click:Connect(function(player)
local findTool = player:WaitForChild("BackPack"):FindFirstChild("AK-101")
if player.leaderstats.Cash.Value >= Price and not findTool then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - Price
Tools:Clone()
Tools.Parent = player:WaitForChild("BackPack")
else
print("something went wrong")
end
end)