Attributes not working as expected

so i hava a combat block system

i wan’t it so that if you punch someone and he’s blocking(attribute) then it would return

but the issue is that the attribute replication between client to server to client is not working

block client:

while true do
	task.wait(0.1)
	
	-- if not attacking and not stunned then
	if pressingF then
		blockAnimationTrack:Play()
		setAttribute:FireServer(player, character, "block")

	else
		blockAnimationTrack:Stop()
		setAttribute:FireServer(player, character, "unblock")

	end
end

setattributes server script(the command doesn’t work):

SetAttributeRemote.OnServerEvent:Connect(function(character, command)
		print(character) -- prints the character
		if command == "block" then -- doesn't work for some reason
			print("setting attribute for this character to blocking true")
			character:SetAttribute("Blocking", true)
			character:GetAttribute("Blocking", true)
		elseif command == "unblock" then
		print("setting attribute for this character to blocking false")
		character:SetAttribute("Blocking", false)
		end

end)

combat client

enemyCharacter:GetAttributeChangedSignal("Blocking"):Connect(function()
						if enemyCharacter:GetAttribute("Blocking", true) then
							
							print("hello attribute blocking...")
							if not (dotProduct >= 0.5) then -- behind or sideways
								print("behind player or sideways")
							elseif dotProduct >= 0.5 then -- if in the front of the player
								print("in front and hes blocking")
								-- play block sound

								return
							end
						else
							print(enemyCharacter:GetAttribute("Blocking"))
						end
					end)

You don’t need to pass the player as one of the :FireServer arguments because it is already received on the server by default. This also means that the first parameter of your .OnServerEvent connection should be the player because that is the first argument that is sent before all of the others.

setAttribute:FireServer(character, "block")
SetAttributeRemote.OnServerEvent:Connect(function(player, character, command)

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