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

Why isn't this working? (True/False value)

Hey there,

I'm new to scripting and I'm sure the issue is small but I'm not seeing any Errors in output

Problem: The local script isn't changing the value to False when clicked.

Local Script:

local onoff = game.StarterGui.DisableBlood.OnOff.Value
local toggle = script.Parent.Frame.Toggle

toggle.MouseButton1Down:Connect(function()
	onoff = false
end)

Script:

		hurt = true
		for _, child in pairs(wep:GetChildren()) do
			if child:IsA("Part") then	
			child.Touched:connect(function(hit)
				if hit.Parent:FindFirstChild("Humanoid") ~= nil and hurt == true then
					soundsclone.Hit:Play()
					hit.Parent:FindFirstChild("Humanoid"):TakeDamage(25)
					hurt = false
					if onoff == true then print(onoff)
					Bleed:FireAllClients(hit)
					end
					elseif onoff == false then
					end

Thanks,

2 answers

Since you changed the value in a local script, only the client can see this change and not the server. I recommend you handle the blood gui on the client since it serves as immediate feedback for the player and it isn't game logic. I'm not sure how you're doing handling the blood gui but I would do something along the lines of:

humanoid.HealthChanged:Connect(function(health)
	if onoff.Value == true then
		--BleedFrame.Transparency == health*0.01
	end
end

If you insist on handling the blood gui on server then you're going to have to fire a remote event from the local script in order to change the bool value and have it replicate on the server.

--local

toggle.MouseButton1Down:Connect(function()
    remoteEvent:FireServer()
end)

--server

remoteEvent.OnServerEvent:Connect(function()
	if onoff.Value == false then
		onoff.Value == true
	else
		onoffValue == false
	end
end

Haven't tested any of the code so let me know if you run into any issues.

1 comment

0

It's being updated on the Server now along with this below but still is acting as if the value were True

		local attacked
		hurt = true	 -- Damage
		for _, child in pairs(wep:GetChildren()) do
			if child:IsA("Part") then	
			attacked = child.Touched:connect(function(hit)
				if hit.Parent:FindFirstChild("Humanoid") ~= nil and hurt == true then
					soundsclone.Hit:Play()
					hit.Parent:FindFirstChild("Humanoid"):TakeDamage(25)
					hurt = false
						if onoff.Value == true then
							Bleed:FireAllClients(hit)
							elseif
							onoff.Value == false then

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