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

(Script cannot search the folder (Weaponcheck) ,from the players) ,not working. Help pls?

Asked by 5 years ago

Script about commands

function onChatted(msg, speaker)
    local source = string.lower(speaker.Name)
    msg = string.lower(msg)

    if msg == "/walk" then
        speaker.Character.Humanoid.Walkspeed = 16

    elseif msg == "/run" then
        speaker.Character.Humanoid.Walkspeed = 20

    elseif msg == "/givesword" and speaker.weaponcheck.Sword.Value == true then -- if the message is /give sword and the bool value in the folder(weapon check) is true then clone sword.
             local sword = game.ReplicatedStorage.Tools.Sword:Clone()
         sword.Parent = speaker.Backpack

    end
end

I was making a commands ,but the line here ,

elseif msg == "/givesword" and speaker.Weaponcheck.Sword.Value == true then
local sword = game.ReplicatedStorage.Tools.Sword:Clone()
sword.Parent = speaker.Backpack

It is not working ,the speaker.Weaponcheck.Sword.Value == true, it cannot search the weaponcheck(folder) and sword in the weaponcheck(bool value) in the speaker (player).

But if I remove it ,like this ,

elseif msg == "/givesword"  then
local sword = game.ReplicatedStorage.Tools.Sword:Clone()
sword.Parent = speaker.Backpack

it will work. Please help me find any errors :) The Weaponcheck is a folder ,while the sword is a bool value Thxx

Answer this question