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

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

Asked by 7 years ago
Edited 7 years ago
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

0
Please add a code block Filipalla 504 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

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.

Ad
Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

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

Answer this question