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

sword script please fix if there is a error and help with a script?

Sword = game.ReplicatedStorage.Sword:Clone()
Sword.Parent = game.Players.LocalPlayer.Backpack
elseif game.Players.LocalPlayer:FindFirstChild("Sword") then
print(game.Players.LocalPlayer.Name.." Already received the sword.")
end
end)

So this is a script to add a sword to there inventory when they get the rank they need.

So could someone fix it if there is a error. And does anyone know how to make it remove the old sword?

thanks

1 comment

0

Please add a code block

2 answers

✓ Accepted answer

Like Ruben said, elseif statements only work with if statements.

Sword = game.ReplicatedStorage.Sword:Clone()

if game.Players.LocalPlayer:FindFirstChild("Sword") then
	print(game.Players.LocalPlayer.Name.." Already received the sword.") 
	else
	Sword.Parent = game.Players.LocalPlayer.Backpack 
end)

You don't even need and elseif statement.

Just check if they have it, if not, then give it to them.

You add an elseif statement without an if statement, that would make your error. (Or your code isn't completely posted.)

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