FireClient messing up idk whats goin on

This is like my 12th post since like 10 days ago lol.
Since I’m new to making combat scripts im trying to innovate on how to make a stun.
The only issue I have is making the stunned player unable to hit.

Im trying to use a remote event to send to the client that It cannot hit anymore

event = game.ReplicatedStorage.Events.Stun
 players = game:GetService("Players")

local Stun = {}

function Stun.stun(hum, dur, dmg)
	local character = hum.Parent
	local player = players:GetPlayerFromCharacter(character)
	print(player.Name)
	event:FireClient(player, dur)
	hum.WalkSpeed = 0
	hum:TakeDamage(dmg)
	task.wait(dur)
	hum.WalkSpeed = 18
end

return Stun

this is the module script.
It prints the name of the hit player, but for some reason regardless I can still hit

stunevent.OnClientEvent:Connect(function(dur)
can_hit = false
can_block = false
can_run = false
wait(dur + 0.4)
can_hit = true
can_block = true
can_run = true
end)

client.
I think it may be an issue with sending duration over. I have no idea honestly.

3 Likes

can i ask where are the can_hit, can_block values located?

I want to help but the information you provided is kinda limited so i need you to answer these questions:

1 - Is the remote event firing at all on the client?
2 - Are you checking that can_hit is equal to true before allowing the player to attack?
3 - When you are calling the stun function, what value are you assigning dur? is it a negative number?

4 Likes

CombatManager;LocalScript;PlayerScripts

1 Like

I made sure the event is firing to the player. I havent gone to check if it fires at all thanks.
im using CAS (ContextActionService) so in the functions on the very first line I put

local function punch()
if input_state == Enum.UserInputState.Begin and can_hit then
--code code
end

3: Dur = positive number

1 Like

Nevermind I’ve figured it out it was something so simple lol

3 Likes

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