I don’t know how to make a tool replacer for my script that where if a player switches to team red(for example) and gets a sword, then switches to blue and gets a gun. I want the script to override(replace) the gun with the sword. Vice-versa the sword replaces the gun.
Here is my own.
– Put this script in ServerScriptService
– Agressive Hero –
local agressiveHeroTools = {
game.ServerStorage.AgressiveHeroSkillTools.FistOverdrive:Clone(),
game.ServerStorage.AgressiveHeroSkillTools.FistFury:Clone(),
game.ServerStorage.AgressiveHeroSkillTools.FinalTremor:Clone(),
game.ServerStorage.AgressiveHeroSkillTools.AngryPunch:Clone()
}
– Finalised Flames –
local finalisedFlamesTools = {
game.ServerStorage.FinalisedFlamesSkillTools.FireSplatter:Clone(),
game.ServerStorage.FinalisedFlamesSkillTools.HeatWave:Clone(),
game.ServerStorage.FinalisedFlamesSkillTools.HotandFast:Clone(),
game.ServerStorage.FinalisedFlamesSkillTools.BurstingAnger:Clone()
}
– Cold Rain –
local coldRainTools = {
game.ServerStorage.ColdRainSkillTools.HeavyWater:Clone(),
game.ServerStorage.ColdRainSkillTools.SplatteringKill:Clone(),
game.ServerStorage.ColdRainSkillTools.WaterOverload:Clone(),
game.ServerStorage.ColdRainSkillTools.WaterOverdrive:Clone()
}
local function addTeamTools(player, teamName)
if teamName == “Agressivehero” then
for _, tool in ipairs(agressiveHeroTools) do
tool:Clone().Parent = player.Backpack
end
elseif teamName == “FinalisedFlames” then
for _, tool in ipairs(finalisedFlamesTools) do
tool:Clone().Parent = player.Backpack
end
elseif teamName == “ColdRain” then
for _, tool in ipairs(coldRainTools) do
tool:Clone().Parent = player.Backpack
end
end
end
local function removePlayerTools(player)
for _, tool in ipairs(player.Backpack:GetChildren()) do
tool:Destroy()
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
wait(5)
removePlayerTools(player)
end)
end)
player.CharacterAppearanceLoaded:Connect(function(character)
local teamName = player.Team.Name
removePlayerTools(player)
addTeamTools(player, teamName)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
removePlayerTools(player)
end
(I dont know why player.CharacterAppearanceLoaded is turned into a code block even though it doesnt have backticks.)
Another one is this.
local animationId = “rbxassetid://123456789”
local damageAmount = 10
local tool = script.Parent
– Connect to the MouseClick event for the tool
tool.Activated:Connect(function()
– Get the player’s character and humanoid
local character = tool.Parent
local humanoid = character:FindFirstChildOfClass(“Humanoid”)
-- Play the animation
local animation = Instance.new("Animation")
animation.AnimationId = animationId
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
-- Connect to the KeyframeReached event to detect when the animation hits another player
animationTrack.KeyframeReached:Connect(function(keyframeName)
if keyframeName == "HitPlayer" then
-- Detect if the animation hit another player and deal damage if it did
local hitPart = animationTrack.Animation.AnimationData:GetMarkerReachedSignal("HitPlayer"):Wait()
local hitCharacter = hitPart.Parent
local hitHumanoid = hitCharacter:FindFirstChildOfClass("Humanoid")
if hitHumanoid and hitHumanoid.Health > 0 and hitCharacter ~= character then
hitHumanoid:TakeDamage(damageAmount)
end
end
end)
end)
I don’t know why it doesnt do damage too though.
(Again I don’t know why 80% of the script turn into a code block.)