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

Is the problem with the if's?

Asked by
RoyMer 301 Moderation Voter
9 years ago

Why is this script not working, are the 2 if's correct? (The Ready.Value works, the rest doesn't most probably because of the conditions)

function onTouch(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid ~= nil then
local Player = game.Players:FindFirstChild(Humanoid.Parent.Name)

if Player.PlayerGui.Ready.Value == true then 
    Player.PlayerGui.Ready.Value = false
    end

if Player.ds.Worn1 == 1 then
    local Clone = game.ReplicatedStorage.Animals.BigHead:Clone()
    Clone.Parent = Player.Character
    local Clone1 = game.ReplicatedStorage.Weapons.Katana:Clone()
    Clone1.Parent = Player.Backpack
    wait(1)
    Player.PlayerGui.Ready.Value = false
end

else
end
end
script.Parent.Touched:connect(onTouch)

0
Try placing print functions in the statements. woodengop 1134 — 9y
0
'Ready' serves as a debounce, and ds is the datastore. RoyMer 301 — 9y
0
It's the else on line 19 that I think is the problem. GoldenPhysics 474 — 9y

1 answer

Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
9 years ago

I think it is the second if

My version:

if Player.ds.Worn1.Value == 1 then
    local Clone = game.ReplicatedStorage.Animals.BigHead:Clone()
    Clone.Parent = Player.Character
    local Clone1 = game.ReplicatedStorage.Weapons.Katana:Clone()
    Clone.Parent = Player.Backpack
    wait(1)
    Player.PlayerGui.Ready.Value = false
end

Edit: Missed out the end

0
Isn't that the same? RoyMer 301 — 9y
0
Still didn't get it to work RoyMer 301 — 9y
Ad

Answer this question