Here is the script. Its not working. Please help me.
local Players = game:GetService('Players') local toolName = 'GoldenSword'
Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) local Humanoid = Character:WaitForChild('Humanoid') Humanoid.Died:Connect(function() if Character:FindFirstChild(toolName) or Player.Backpack:FindFirstChild(toolName) then
local.player.torso = ("VeryYellow")-- here, after said player dies is where the effect would be end -- check tool name end) -- Died end) -- CharacterAdded
end) -- PlayerAdded
Your mistake is very simple. Allow me to explain.
On this line, what is interpreted by Lua? The answer: Not what you'd think it would be.
local.player.torso = ("VeryYellow")
torso
may refer to a value of key player
, which in turn may refer a key of table local
. Since there is no table named local
, Lua stops and raises an error. There is also no key named player
and no value of player
named torso
. In other words, you're doing it incorrectly.
If you meant to use BrickColor
to refer to VeryYellow
, you may use the Gold
color. The player's Torso has a BrickColor
property which specifies the torso's BrickColor. (All BaseParts
share this property.) A BrickColor can be retrieved using the BrickColor.new()
constructor function, which can take a string determining the BrickColor
to use. In this case, you'd want Gold
because you desire a golden kill effect. The fix here is to do Character.Torso
, since Character
refers to the player's character and is already specified from the CharacterAdded
signal. Its BrickColor should be assigned to the Gold BrickColor.
Replace your script with the following:
local Players = game:GetService('Players') local toolName = 'GoldenSword' Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) local Humanoid = Character:WaitForChild('Humanoid') Humanoid.Died:Connect(function() if Character:FindFirstChild(toolName) or Player.Backpack:FindFirstChild(toolName) then for _, v in pairs(Character:GetChildren()) do if v.ClassName == "MeshPart" then v.BrickColor = BrickColor.new("Gold") v.Material = Enum.Material.Neon end end end -- check tool name end) -- Died end) -- CharacterAdded