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

How do I transfer a clonedPart into another remote event?

Asked by 6 years ago

Okay, I apologize if this is too much to digest, but I really need some help for this problem. (at times I believe there is no solution to this problem.);

game.ReplicatedStorage.clipEvent.OnServerEvent:Connect(function(player,gun)
    local checkV = gun.Debounces.alreadyOpen
    if x then
        x = false
                local cloneClip = game.ReplicatedStorage.Clip:Clone()
                cloneClip.Name = "9mm Ammo"
                cloneClip.Parent = workspace
                cloneClip.CFrame = player.Character.LeftHand.CFrame
                cloneClip.Anchored = false
                local guiclone = game.ReplicatedStorage.GUI:Clone()
                guiclone.Parent = cloneClip
                local magnitude = (player.Character.HumanoidRootPart.Position - cloneClip.Position).Magnitude
                coroutine.wrap(function()
                    while wait() do
                        magnitude = (player.Character.HumanoidRootPart.Position - cloneClip.Position).Magnitude
                    end
                end)()
        coroutine.wrap(function()
                while wait() do
                    if checkV.Value== 0 then
                            checkV.Value = 1
                                if magnitude <=10 then
                                    guiclone.Enabled = true
                                else
                                    guiclone.Enabled = false
                                end
                            end
                        end
                    end)()
                wait(3)
                x = true
        end
end)

^^ This is the event, It's supposed to clone a clip copy, and move it to the players left hand. (this works fine), now the GUI clone is cloning a billboardGUI, that says "Press F to pick up ammo". It is supposed to show whenever the magnitude between the player and the clonedclip is smaller than or equal to 10. (this also works fine.),

The checkV debounce is to stop 2 GUI's showing up if there is 2 ammo on the floor. (so that the player picks up 1 piece of ammo), the value changes back to 0 when the clonedclip on the floor is deleted, and the ammo is added to the gun.

^ This works, but now I don't know how to transfer the clonedClip into another remote event. since it produces a lot of clonedclips with the same name.

Please, any suggestions leave them. Anything helps!

0
Pass the cloneClip as a parameter, or use a RemoteFunction to return that clonedClip. User#19524 175 — 6y

Answer this question