BoolValue doesnt works

  1. What do you want to achieve?
    I want to make a sword that deals damage only when the canDamage value = true

  2. What is the issue?
    It is simply doesnt works! It become true and nothing happens for some reason

  3. What solutions have you tried so far?
    I’ve tried cheking it with “if”, but it does’nt work

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		local cDvalue = script.Parent.Parent.Parent.canDamage
		if cDvalue.Value == true then
			print('Worked!')
			hit.Parent:FindFirstChild('Humanoid'):RemoveAccessories()
		else
			return
		end
	end
end)

Oh and also, idk you guys will need this or not but it becomes true for 0.5 seconds

is the code hit.Parent:FindFirstChild('Humanoid'):RemoveAccessories() supposed to simulate a damage function? if not so you can deal damage to humanoid via :Takedamage()

No, everything is alright, this is admin Accessory deleting sword. But it doesn’t matter, i have a problem with boolean not this part

And can you perhaps show us what kind of errors it brings on the output?

Output is empty
its like doesn’t check if cDvalue is true

Might be collisions then
Do both parts(Character and Sword’s hitbox) have Cantouch enabled? if one of them don’t, it won’t function

No its not collision, i said that bool value activates, but in the hitbox script the “if” check doesnt works for some reason, it may be bc of the timing with wait()

Can you show the Boolvalue’s script?

Are you changing the value in a local script perhaps?

tool.Activated:Connect(function()
	if debounce == true  then
		debounce = false
		if timeActivate == 0 then
			timeActivate = 1
			cDvalue.Value = true
			AnimTrack:Play()
			SwingSound:Play()
		elseif timeActivate == 1 then
			timeActivate = 2
			cDvalue.Value = true
			AnimTrack1:Play()
			SwingSound:Play()
		elseif timeActivate == 2 then
			timeActivate = 0
			cDvalue.Value = true
			AnimTrack2:Play()
			FswingSound:Play()
		end
		wait(0.5)
		cDvalue.Value = false
		debounce = true
	end
end)

P.S. - timeActivate to get how much times tool activated, for different animations

1 Like

Local script or normal Script?

Changing in local and cheking in sever

Yep that doesnt work changes on the client dont replicate on the server make it a server script

(or use a remote event)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.