Apparently, everything seems slower on serverside than on clientside. I had to add wait(0.05) between each step, and it still sometimes doesn't work. Sometimes the item doesn't save Position in time and its right next to me now, and sometimes I get flung back because CanCollide doesn't become false in time. All of this seemed perfectly fine in clientside, until I had to make some adjustments to finally fix this inventory thing.
game.ReplicatedStorage.ItemToBackpack.OnServerEvent:Connect(function(player, item) pos = item.Position item.Parent.ItemValue.Value = false item.CanCollide = false transp = item.Transparency wait(0.05) local Info = TweenInfo.new(0.05) local Goal = {} Goal.CFrame = player.Character.HumanoidRootPart.CFrame local Tween = tweenservice:Create(item,Info,Goal) Tween:Play() if player.Character.HumanoidRootPart:FindFirstChild("ItemTakeSound") then player.Character.HumanoidRootPart.ItemTakeSound:Play() else end wait(0.05) item.Transparency = 1 item.Position = workspace.ItemHolder.Position if item.Parent:FindFirstChild("DroppedItem") then local itemClone = game.Lighting[item.Name]:Clone() itemClone.Parent = player.Backpack itemClone.LocalScript.Disabled = false item.Parent:Destroy() print(item.Name .. " Taken") else item.CanCollide = true wait(0.05) item.Position = pos item.Transparency = transp item.Parent.ItemValue.Value = true local itemClone = game.Lighting[item.Name]:Clone() itemClone.Parent = player.Backpack itemClone.LocalScript.Disabled = false print(item.Name .. " Taken") end end)
Some of the parts in this script doesn't correlate to what I'm trying to explain here. Some bit of help would be gladly appreciated.