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 it working to transfer a hit function to a remoteevent? [UPDATED]

So i am woundering why isn't this working to transfer this hit function from a local script to a server script with a remote event.

Local Script:

mouse.Button1Down:connect(function()
	local value = Stats[Equipped]["Cooldown"]
	if not cooldown and not Attacking then
		local playAnim = char.Humanoid:LoadAnimation(anim)
		playAnim:Play()
		if not cooldown then
			Attacking = true
		end
		
		if Class == "Axe" then
			local weapon = ActiveWeapon:FindFirstChild(Equipped)
			if Attacking == true then
				weapon["Blade"].Touched:connect(function(hit)
					if hit.Parent:FindFirstChild("Humanoid") then
						if not deb then
							deb = true
							Remotes["TakeDamage"]:FireServer(hit, Stats[Equipped]["Damage"])
						end
					end
				end)
			end
		end
		
		-- WEAPON COOLDOWN SYSTEM --
		for i = value,0,-1 do
			cooldown = true
			wait(.65)
		end
		cooldown = false
		Attacking = false
		deb = false
	end
end)

Server Script:

Remotes["TakeDamage"].OnServerEvent:connect(function(hit, dmg)
	print(hit.Parent.Name)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent:FindFirstChild("Humanoid"):TakeDamage(dmg)
	end
end)

6 comments

0

Why do you need a remote event... just use the server script

0

Cause i need it to fire when you click the mouse

0

Please provide more context, Any errors? How exactly is it not working. no damage is being outputted, the event isn't even firing? Also, show us the full local script, where you define the remoteevent. Also, use :Connect instead of :connect

0

Whats the differense between :connect and :Connect?

0

There are 2 differences. 1) They are capitalized differently 2) :connect is deprecated, and :Connect is not.

0

Using :Connect will appease hiimgoodpack so he doesn't get mad at you.

1 answer

you shouldn't need a remoteevent if i'm interpreting this correctly.

weapon["Blade"].Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if not deb then
			deb = true
			hit.Parent.Humanoid:TakeDamage(dmg)
			wait(2)
		end
		deb = false
	end
end)

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