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

Cloning breaks my tool, any help? [Elaboration in desc]

Asked by 3 years ago

I have my gun in ReplicatedStorage and a simple script in a GUI which when you press, the gun gets cloned and transferred to your backpack. The script works but when I equip the gun it doesn't work at all but if I directly put the gun in the StarterPack and play, it works perfectly fine. I have no idea how to fix this and have searched online and found nothing.

Here is the GUI Script:

local tool = game.ReplicatedStorage.Musket
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    tool:Clone()
    tool:Clone().Parent = player.Backpack
end)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Try making a Remote Event and making the script fire it.

    local tool = game.ReplicatedStorage.Musket
    local player = game.Players.LocalPlayer
        local event  = game.ReplicatedStorage.Clone --Name the event that

    script.Parent.MouseButton1Click:Connect(function()
        event:FireServer()
    end)

My bad. Actually just make a server script in serverscriptservice and use the following code

game.ReplicatedStorage.Clone.OnClientEvent:Connect(Function(player)
local b = game.ReplicatedStorage.Musket:Clone()
b.Name = "Musket"
b.Parent = player.Backpack
end)
0
So I added a RemoteEvent called 'Clone' in ReplicatedStorage, created the server script in serverscriptservice and used the code aaand it didn't appear in the backpack. Shouldn't it fire once I press on the GUI? TheJacksterYT 19 — 3y
0
The GUI is located in StarterGui > Class > Frame > Infantry [ButtonLabel] TheJacksterYT 19 — 3y
0
What script are you using to fire the event? coolkid222131 19 — 3y
0
Wait! Mb, I forgot to add the end) try it again but paste the new scripts where they need to go. coolkid222131 19 — 3y
Ad

Answer this question