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

What could be causing the normal LinkedSword to not function when cloned?

Asked by 4 years ago

I have tried to make a GUI button that gives you an item when you click on it, works pretty well, until I noticed that the ClassicSword or LinkedSword does not function properly after cloning it. Basically, you can only hold the sword, and it does nothing else.

Here is my giver script:

local p = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect (function()
 local tool = script.Parent.LinkedSword:clone()
tool.Parent = p.Backpack
end)
0
Hey! You yeah you! Don't expect us to fix free models! If you want us to help, make your own sword. BashGuy10 384 — 4y
0
You are using a local script, which means your code is client-sided and will not work with this. JJBloxxer has the correct solution Despayr 505 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

In the ReplicatedStorage insert a RemoteEvent and your sword. Next, insert a Script inside of the ServerScriptService and in it type the following code.

local event = game.ReplicatedStorage.RemoteEvent

event.OnServerEvent:Connect(function(player)
    game.ReplicatedStorage.ClassicSword:Clone().Parent = player.Backpack
end)

Inside your button insert a LocalScript and in it type the following code.

local event = game.ReplicatedStorage.RemoteEvent

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

Answer this question