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

Model from ReplicatedStorage wont show for everybody when moved to workspace?

Asked by
BiIinear 104
5 years ago

I've been developing an inventory system, so far the progress is going great. But this error just overall confuses me. It probably has to do something with it being a localscript, or the model coming from ReplicatedStorage.

wait(5)
local player = game.Players.LocalPlayer

--Drop item
script.Parent.MouseButton2Click:Connect(function()
    if script.Parent.ItemNameValue.Value ~= '' then
        if player.Backpack:FindFirstChild(script.Parent.ItemNameValue.Value) then
            local itemclone = game.ReplicatedStorage[script.Parent.ItemNameValue.Value]:Clone()
            player.Backpack[script.Parent.ItemNameValue.Value]:Destroy()
            itemclone[script.Parent.ItemNameValue.Value].CanCollide = true
            itemclone[script.Parent.ItemNameValue.Value].Anchored = false
            itemclone[script.Parent.ItemNameValue.Value].Position = player.Character.HumanoidRootPart.Position
            local dropclone = game.Lighting.Values.DroppedItem:Clone()
            dropclone.Parent = itemclone
            itemclone.Parent = workspace
            script.Parent.ItemNameValue.Value = ''
            script.Parent.DescriptionValue.Value = ''
            script.Parent.Active = false
            script.Parent.Image = ''
            print("Item dropped")
        else
            print("Unable to drop, item equipped")
        end
    end
end)

What the script does is when you right click on an occupied slot in the inventory, it drops the item into the workspace. This works by cloning the exact item from ReplicatedStorage and parenting it to workspace. But apparently, it gets parented to workspace, but it wont show for any other players. I've even tried cloning from CurrentCamera. Does anybody have a solution to this? I think the problem is coming from the fact that a localscript is firing this, I'm not sure.

1 answer

Log in to vote
1
Answered by
cegberry 432 Moderation Voter
5 years ago
Edited 5 years ago

You can’t clone stuff and then put it in another parent, with a LocalScript because of FilteringEnabled; FilteringEnabled is when a client make changes, the server won’t make the change for other clients; You may want to make it so, a LocalScript doesn’t do the cloning part, but the server does it

0
That makes a lot of sense, thanks. BiIinear 104 — 5y
Ad

Answer this question