Idea The idea is to simple detect what the player shoots, and deal with it accordingly.
Problem The Problem is on line 21, im sure its a simple fix but im not positive. Thanks :D
Code
game.ReplicatedStorage.Remotes.Shoot.OnServerEvent:connect(function(player, hit, damage) if hit then if hit.Parent:FindFirstChild("Humanoid") then if hit.Name == "Head" then hit.Parent.Humanoid:TakeDamage(damage * 2) else hit.Parent.Humanoid:TakeDamage(damage) end elseif hit.Parent.Parent:FindFirstChild("Humanoid") and not hit.Parent:IsA("Tool") then if hit.Name == "Handle" then hit.Parent.Parent.Humanoid:TakeDamage(damage * 2) else hit.Parent.Parent.Humanoid:TakeDamage(damage) end end if hit.Parent:FindFirstChild("LastHit") then hit.Parent.LastHit.Value = player elseif hit.Parent.Parent:FindFirstChild("LastHit") then hit.Parent.Parent.LastHit.Value = player end if hit.Parent == game.Workspace.Core and player.TeamColor == "Crimson" then hit.Parent.Health.Value = hit.Parent.Health.Value - damage hit.Parent.LastHit.Value = player end end end) game.ReplicatedStorage.Remotes.ChangeWalkSpeed.OnServerEvent:connect(function(player, speed) if player.Character and player.Character.Humanoid then player.Character.Humanoid.WalkSpeed = speed end end)
Hai> Hai
Your problem is that you're trying to compare a string value to a BrickColor value. These are both different datatypes, so to use them together you need to translate one to the other. To do this, we'll simply change the string into a BrickColor.
Ex.
brickcolor = BrickColor.new("Crimson") --Sets BrickColor value string = "Crimson" --Sets a string value
Ok, now to apply this to your script, we'll change the string to a BrickColor like used in the example above:
game.ReplicatedStorage.Remotes.Shoot.OnServerEvent:connect(function(player, hit, damage) if hit then if hit.Parent:FindFirstChild("Humanoid") then if hit.Name == "Head" then hit.Parent.Humanoid:TakeDamage(damage * 2) else hit.Parent.Humanoid:TakeDamage(damage) end elseif hit.Parent.Parent:FindFirstChild("Humanoid") and not hit.Parent:IsA("Tool") then if hit.Name == "Handle" then hit.Parent.Parent.Humanoid:TakeDamage(damage * 2) else hit.Parent.Parent.Humanoid:TakeDamage(damage) end end if hit.Parent:FindFirstChild("LastHit") then hit.Parent.LastHit.Value = player elseif hit.Parent.Parent:FindFirstChild("LastHit") then hit.Parent.Parent.LastHit.Value = player end if hit.Parent == game.Workspace.Core and player.TeamColor == BrickColor.new("Crimson") then hit.Parent.Health.Value = hit.Parent.Health.Value - damage hit.Parent.LastHit.Value = player end end end) game.ReplicatedStorage.Remotes.ChangeWalkSpeed.OnServerEvent:connect(function(player, speed) if player.Character and player.Character.Humanoid then player.Character.Humanoid.WalkSpeed = speed end end)
Ok, well now the code should work correctly! Anyways, if you have any further problems/questions, please leave a comment below, and I'll see what I can do. Hope I helped :P