Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CanCollide and Position not saving as quickly?

Asked by
BiIinear 104
4 years ago

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.

0
Mind to explain the situation further? It's hard to fix it if we can't see what's happening. A few images on the situation will help a lot. SCP774 191 — 4y
0
Yea i do have to Admit its mostly roblox's fault because their Servers can not handle anything infact if their server could handle more than their clients that would litterly fix nearly all FE shutdown script Oskar2266001 3 — 4y
0
SCP774 not sure why you need images... I take an item, and sometimes it doesn't save its position before tweening. Then it just stays right next to me and the new position is saved. I guess I'd have to make a backup position. BiIinear 104 — 4y

Answer this question