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

Is the problem with the if's?

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)

3 comments

0

Try placing print functions in the statements.

0

'Ready' serves as a debounce, and ds is the datastore.

0

It's the else on line 19 that I think is the problem.

1 answer

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

2 comments

0

Isn't that the same?

0

Still didn't get it to work

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