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

How can I make my Giver... well give?

Asked by 10 years ago

Please do not edit my variable or make them more efficient by changing my script! There are two parts to this that has script. This is my part called Change which when touched, changes a boolean value named Enable to false or true. This boolean is going to be used for another script as well. Here is the script in Change.

SP = script.Parent
Debounce = false


SP.Touched:connect(function(hit)
    local Human_Check = hit.Parent:FindFirstChild("Humanoid")
    if Human_Check ~= nil and SP.BrickColor ==  BrickColor.new("Bright green") and Debounce == false then 
        Debounce = true
        SP.BrickColor = BrickColor.new("Bright red")
        SP.Parent.Enable.Value = false
        wait(4)
        Debounce = false
    elseif Human_Check ~= nil and SP.BrickColor == BrickColor.new("Bright red") and Debounce == false then
        Debounce = true
        SP.BrickColor = BrickColor.new("Bright green")
        SP.Parent.Enable.Value = true
        wait(4)
        Debounce = false
    end
end)

Now this is the part where if I touch, it will tell me if I need to wait before I can get the Sword or it will give me the sword. The parts name is Giver and the script inside is

SP = script.Parent
SPP = script.Parent.Parent
Debounce = false
Tool = game.ReplicatedStorage:FindFirstChild("Sword")-- Change sword to the weapons name
SP.Touched:connect(function(hit)
    if Debounce == false then Debounce = true
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr then
            if SPP.Enable.Value == false then
                SP.Transparency = 0.5
                wait(0.1)
                SP.Transparency = 0
                local msg = Instance.new("Message",plr.PlayerGui)
                msg.Text = "Please wait a few seconds and try again"
                wait(3)
                msg:Destroy()
                Debounce = false
            elseif Debounce == false then Debounce = true
                if plr then
                    if SPP.Enable.Value == true then
                    Tool:Clone().Parent = plr.PlayerGui
                    end
                end

            end
        end
    end
end)

I am not getting my Sword at all. Please help and explain what I did wrong? At first I'm able to get my message, by afterwards I cannot get the message or Sword(I never got the Sword in the first place)

1
Why are you using two scripts? NotsoPenguin 705 — 10y
0
Do you have the tool in the replicated storage? bobder2 135 — 10y
0
Also you could try putting prints into each of the if statements to see where the script is going and what it's doing. bobder2 135 — 10y

Answer this question