local player = game.Players.LocalPlayer local character = game.Workspace[player.Name].Humanoid local inventory = player.PlayerGui.ScreenGui.Pages.Inventory local itemsforinventory = game.ServerStorage.ItemsForInventory local mouse = player:GetMouse() local gathering = false script.Parent.Activated:connect(function() local target = mouse.Target local playerwalkspeed = character.WalkSpeed local range = player:DistanceFromCharacter(target.Position) if not gathering and script.Parent.Parent.Name == player.Name and target.Name == "FoliageLarge" or target.Name == "Apple" or target.Name == "WoodTree" or target.Name == "StoneLarge" or target.Name == "StoneMedium" or target.Name == "StoneSmall" or target.Name == "Orange" then if range <= 30 and player.PlayerGui.ScreenGui.Pages.Inventory.ItemsInInventory.Value < 40 then gathering = true script.Disabled = true character.WalkSpeed = 0 wait(target.GatherTime.Value) target:Remove() player.PlayerGui.ScreenGui.Pages.Inventory.ItemsInInventory.Value = player.PlayerGui.ScreenGui.Pages.Inventory.ItemsInInventory.Value + 1 print(player.Name.." has gathered a "..target.Name) script.Disabled = false character.WalkSpeed = playerwalkspeed local itemgui = itemsforinventory[target.Name][target.Name..'Gui']:Clone() itemgui.Parent = player.PlayerGui.ScreenGui.Pages.Inventory gathering = false end end end)
I used to have a file with the working code but it was lost ;-; There's no error. Before, the player would click say an apple then they'd stop for the specified gather time, it'd go into their inventory, and that would be that. Nothing happens now. Help is much appreciated.
I reccomend using Button1Down Ex:
local player = game.Players.LocalPlayer local character = game.Workspace[player.Name].Humanoid local inventory = player.PlayerGui.ScreenGui.Pages.Inventory local itemsforinventory = game.ServerStorage.ItemsForInventory local mouse = player:GetMouse() local gathering = false mouse.Button1Down:connect(function() local target = mouse.Target local playerwalkspeed = character.WalkSpeed local range = player:DistanceFromCharacter(target.Position) if not gathering and script.Parent.Parent.Name == player.Name and target.Name == "FoliageLarge" or target.Name == "Apple" or target.Name == "WoodTree" or target.Name == "StoneLarge" or target.Name == "StoneMedium" or target.Name == "StoneSmall" or target.Name == "Orange" then if range <= 30 and player.PlayerGui.ScreenGui.Pages.Inventory.ItemsInInventory.Value < 40 then gathering = true character.WalkSpeed = 0 wait(target.GatherTime.Value) target:Remove() player.PlayerGui.ScreenGui.Pages.Inventory.ItemsInInventory.Value = player.PlayerGui.ScreenGui.Pages.Inventory.ItemsInInventory.Value + 1 print(player.Name.." has gathered a "..target.Name) character.WalkSpeed = playerwalkspeed local itemgui = itemsforinventory[target.Name][target.Name..'Gui']:Clone() itemgui.Parent = player.PlayerGui.ScreenGui.Pages.Inventory gathering = false end end end)
Also if you disable your script it wont run anything after it.