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

Tools/Swords Not working when :Clone()ed and parent set to localplayer?

Asked by 4 years ago

So im trying to create a sword fighting arena for my roblox game, and ive got the sword giving platform down but i when i clone the sword (from and part of the game, lighting, replicatedStorage) the animations dont play and the sword is basically a paperweight. im using the default sword made by roblox, and ive tried tons of other swords and they dont work either. classic roblox sword when cloned: https://gyazo.com/45bbce474c1d0f64a98743f4279ed979 classic roblox sword when in starterpack : https://gyazo.com/20bbf2e9ac9ab553ba03dac1cc3bc66b

and solution to this, the script is in starterplayer.starterplayerscripts, the script is

wait(1)
function checkiftool(username, toolname)
    if game.Workspace[username]:FindFirstChild(toolname) ~= nil or game.Players[username].Backpack:FindFirstChild(toolname) ~= nil then
            return true
    else
        return false
    end
end
function toolplace(username, toolname)
    if game.Workspace[username]:FindFirstChild(toolname) ~= nil then
        return game.Workspace[username][toolname]
    else
    return game.Players[username].Backpack[toolname]        
    end
end
while wait(0.4) do
local Ray = Ray.new(game.Workspace[game.Players.LocalPlayer.Name].HumanoidRootPart.Position, Vector3.new(0, -10, 0))
local FloorPart = workspace:FindPartOnRay(Ray, game.Players.LocalPlayer.Character)
 local toolstate = checkiftool(game.Players.LocalPlayer.Name, 'ClassicSword')
if FloorPart == game.workspace.ArenaPart then
if toolstate == false then
    sword = game.Lighting.ClassicSword:Clone()
    sword.Parent = game.Players.LocalPlayer.Backpack
end
else
if toolstate == true then 
    toolplace(game.Players.LocalPlayer.Name, 'ClassicSword'):Destroy()
end
    end
end

its a localscript fyi

0
So, the problem is you're importing a sword from the Toolbox, and when you clone it into a player's backpack, it no longer has working scripts? User#19492 0 — 4y
0
yes basically, it works if i put the tool in starterpack tho JoeydiseaseI 0 — 4y
0
Honestly, I recommend making your own weapon. It doesnt have to be fancy, just some touch events and server events. Custom animations are typically your biggest problem, so making custom animations and doing it from scratch ensures you know how to fix your own problems User#19492 0 — 4y

Answer this question