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

How do I make it that when the Forcefield on you is removed, you get a sword?

Asked by 4 years ago

So I wanted to put the sword as a child of the local script, and the local script would clone it's child and parent it to your backpack when the Forcefield disappears. The local script is in the StarterCharacterScripts file. Here's the script:

local sword = script.ClassicSword
wait(3) --this is the forcefield duration time
local swordclone = sword:Clone()
swordclone.Parent = game.Players.LocalPlayer.Backpack

But when I test it, my first spawn I had the sword. When I reset my character, I did not get the sword. I need help

1 answer

Log in to vote
0
Answered by 4 years ago

i think i got it. (it worked in roblox studio)

game:GetService('Players').PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        wait(3)
        local swordclone = game.ReplicatedStorage.sword:Clone()
        swordclone.Parent = player.Backpack
        character:WaitForChild("Humanoid").Died:Connect(function()
        wait(8) --add the respawntime with the forcefield  duration time. (respawn time is found in players)
        local swordclone = game.ReplicatedStorage.sword:Clone()
        swordclone.Parent = game.Players.LocalPlayer.Backpack
        end)
    end)
end)

i hope it helped you

0
Wasnt working :( DaMadnessIsBack 17 — 4y
Ad

Answer this question