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

Why does my cloned sword only work on solo mode?

Asked by 9 years ago

Basically once a player clicks on a button within this LocalGUI they should have a fully working Sword in their backpack, however they only get the ability to hold it, as if the scripts didn't clone over. I don't have this problem with any of the other tools, and I have tried multiple swords, all seem to not work.

SwordButton.MouseButton1Down:connect(function()
        LoadoutFrame:Destroy()
        local Sword = game.ReplicatedStorage.ClassicSword
        local SwordClone = Sword:Clone()
        SwordClone.Parent = game.Players.LocalPlayer.Backpack

    end)

Running this through output gave me the message:

Handle is not a valid member of Tool

1 answer

Log in to vote
0
Answered by 9 years ago

I have had the same issue, too. I have noticed that cloning in a LocalScript doesn't always go correctly, as LocalScripts on the Client, and normal Scripts run on both the Server and Client. Try the code below in a normal Script inside of the Gui:

Player = script.Parent.Parent.Parent

SwordButton.MouseButton1Click:connect(function()
    LoadoutFrame:remove()
    local Sword = game.ReplicatedStorage:FindFirstChild("ClassicSword")
    if Sword then
        local SwordClone = Sword:Clone()
        SwordClone.Parent = Player.Backpack
    end
end)
0
I'm a little new to working with GUI, I'm not sure if it would be possible to move that into a normal script without having to completely rework the rest of the GUI to get to that 'stage' Hazazaz 0 — 9y
0
You would only have to change game.Players.LocalPlayer to script.Parent.Parent.Parent Shrekerly 70 — 9y
Ad

Answer this question