Hello so, i’m creating a gun for my map, but i have doubts about Client and Server.
For example: in the video below I use the weapon against a TestHumanoid, but the script that applies damage to Humanoid is in a LocalScript:
script:
--LocalScript in Gun
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
local bullets = player.PlayerGui:WaitForChild("GunGui"):WaitForChild("Bullets")
local shotsound = tool.Gunfire
tool.Equipped:Connect(function()
bullets.Visible = true
mouse.Icon = "rbxgameasset://Images/Icon"
tool.Activated:Connect(function()
shotsound:Play()
print(mouse.Target)
if mouse.Target then
if mouse.Target.Parent:FindFirstChild("Zumanoid")then
mouse.Target.Parent:FindFirstChild("Zumanoid"):TakeDamage(5)
elseif mouse.Target.Parent.Parent:FindFirstChild("Zumanoid") then
mouse.Target.Parent.Parent:FindFirstChild("Zumanoid"):TakeDamage(5)
end
end
end)
tool.Unequipped:Connect(function()
bullets.Visible = false
mouse.Icon = ""
end)
end)
Notice that for the server TestHumanoid also died
My question is: Why did the Humanoid Test also die to the server if it happened only on the client? (LocalScript)