(Please, don't link me the blog threat, i have read it and it didn't help me)
So i have a script which gives me a sword when i click the button (it's a LocalScript) and it works only in studio, why?
local swordclone = script.Parent.LinkedSword:Clone() local player = game.Players.LocalPlayer local button = script.Parent function clicked() script.Parent.LinkedSword:Clone() swordclone.Parent = player.Backpack end script.Parent.MouseButton1Down:connect(clicked)
I had to hurry so sorry for not explaining, I hope it works.
repeat wait() until game.Players.LocalPlayer.Character --Be on the safe side local Sword = script.Parent:WaitForChild("LinkedSword") local player = game.Players.LocalPlayer local button = script.Parent script.Parent.MouseButton1Click:connect(function() if player.Character:FindFirstChild('LinkedSword') == nil then Sword:Clone().Parent = player.Backpack end end)
You aren't really using your variables how you should
local sword = script.Parent.LinkedSword local player = game.Players.LocalPlayer local button = script.Parent function clicked() sword:Clone().Parent = player.Backpack end button.MouseButton1Down:connect(clicked)
This is simple you forgot that for the server it takes longer to load the sword and the local script runs faster so it can't find the sword cusess it's not there so the script breaks the start. try this
local Sword = script.Parent:WaitForChild("LinkedSword") local player = game.Players.LocalPlayer local button = script.Parent script.Parent.MouseButton1Click:connect(function() script.Parent.LinkedSword:Clone().Parent = player.Backpack end)