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

Why does this damaging script only damage through one players client?

Hey, i'm a beginner scripter trying to make a damaging script whenever you're touching a player and click. But for whatever reason the damage only shows on the client damaging the player. But it does not actually shows on the player being damaged (I hope you understand what I mean.) Code snippet below:

local character = script.Parent 
local humanoid = character:WaitForChild("Humanoid")

local touchedConnection = humanoid.Touched:Connect(function(hit, limb)
	if (hit.Name == "LeftArm" or hit.Name == "RightArm" or hit.Name == "Torso" or hit.Name == "Head") then
		local Player = game.Players.LocalPlayer
		local Mouse = Player:GetMouse()
		Mouse.Button1Down:Connect(function()
			wait(0.3)
			hit.Parent.Humanoid:TakeDamage(5)
		end)
	end
end)

1 comment

0

Oh, and this is a local script inside of startercharacterscripts.

1 answer

It's because your script is a local script. Try writing your code in a server script for damaging other players instead.

8 comments

0

Alright, thank you so much! I'll tell you if this works.

0

Sorry, what do you mean by server script? I literally started learning basic lua a few days ago so i'm very new to this stuff and I don't know anything about it's vocabulary.

0

It's just called a "script" in roblox studio. .Judging by the fact you don't know what a server script is you should continue to learn roblox lua instead of jumping to things you don't know yet. Learning the difference between a local script and a server script is one of the first things you should learn about roblox lua.

0

So should I use a remote event to activate a server script to damage the player I hit?

0

And I was just confused on what you were saying because most of the youtubers that I watch referred to it as just a "script" because that's what it is. Thanks for all your help either way as I got the issue solved by using remote events.

0

Your youtubers are outdated and are probably before the forced FE update. Also, never add a remote event to deal damage, as exploiters can spam fire such an event and that's the end of players joining your game. Also, never kill a player on the client. It breaks your game.

0

Well crap. I'll try to remake everything. I really messed up. Thank you so much.

0

Hahaha! You're so funny!

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