Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

1 comment

0

Wasnt working :(

This discussion is preserved as it was. New answers, comments, and votes are closed.