Trying to only be able to place 3 bananas on the ground, and then remove the tool and then needing to buy the tool every time... This is my local script:
tool = script.Parent
player = game.Players.LocalPlayer
replicatedSotrage = game.ReplicatedStorage
script.Parent:WaitForChild("BananLeft")
BananLeft = script.Parent.BananLeft
tool.Equipped:Connect(function(mouse)
mouse.Icon = "rbxgameasset://Images/MouseIconBanana"
player.PlayerGui.ScreenGui.BananCounter.Visible = true
mouse.Button1Down:Connect(function()
local position = mouse.Hit.p
local head = player.Character.Head
local distance = (head.Position - position).magnitude
if distance < 25 and BananLeft > 0 then
replicatedSotrage.SpawnBanana:FireServer(position)
BananLeft.Value = BananLeft.Value - 1
end
if BananLeft.Value == 0 then
game.ReplicatedStorage.DestroyTool:FireServer(player.Backpack.BananaDropper, player.StarterGear.BananaDropper)
end
end)
end)
tool.Unequipped:Connect(function(mouse)
player.PlayerGui.ScreenGui.BananCounter.Visible = false
end)
Server script:
replicated = game.ReplicatedStorage.SpawnBanana.OnServerEvent:Connect(function(player, position)
local banana = game.ServerStorage.Banana:Clone()
banana.Parent = game.Workspace
banana.Position = Vector3.new(position.X, position.Y, position.Z)
end)
game.ReplicatedStorage.DestroyTool.OnServerEvent:Connect(function(player, backpackTool, starterGearTool)
backpackTool:Destroy()
starterGearTool:Destroy()
end)
This is the tool ancestry:
BananaDropper (Tool) DropBanana (Local script) BananLeft (IntValue) Handle (Part)
Please help Thanks Is this osmething with that the intValue is inside the player??

2 comments
legend
wut