local function CreatObject(hit, dmg) local ObjModel = Instance.new("Model", workspace) local Obj = Instance.new("Part", ObjModel) Obj.Material = "Neon" Obj.Transparency = 1 Obj.BrickColor = BrickColor.new("Pastel yellow") Obj.Position = hit.Parent:FindFirstChild("Head").Position + Vector3.new(math.random(-1.6, 1.6),2,math.random(-1.6,1.6)) Obj.Anchored = true Obj.CanCollide = false Obj.Shape = "Ball" Obj.Size = Vector3.new(.75, .75, .75) local GUI = script.BillboardGui:Clone() GUI.Adornee = Obj local Even = math.floor(dmg + .5) GUI.TextLabel.Text = Even.." damage" GUI.Parent = ObjModel
local ObjPos = Instance.new("BodyPosition", Obj) Obj.Position = Vector3.new(0,7.85,0) for i = 1, 0, .1 do Obj.Transparency = i GUI.TextLabel.TextTransparency = i GUI.TextLabel.TextStrokeTransparency = i wait() end wait() for i = 0, 1,.1 do Obj.Transparency = i GUI.TextLabel.TextTransparency = i GUI.TextLabel.TextStrokeTransparency = i wait() end return ObjModel
end
local function Damage(Player,hit,Enemy) local Character = Player.Character local Tool = Character:FindFirstChildOfClass("Tool") if(not Enemy)or (not hit) or (not Tool) then return end local Core = hit.Parent:FindFirstChild("HumanoidRootPart") if(not hit.Parent)or(not Core) then return end if(game.Players:GetPlayerFromCharacter(Enemy.Parent))then return end local dmg = math.random(Tool.Min.Value, Tool.Max.Value) Enemy:TakeDamage(dmg) if Enemy.Health <= 0 then local creator = Instance.new("ObjectValue", Enemy) creator.Name = "Creator" creator.Value = Character end local ObjModel = CreatObject(hit, dmg) ObjModel:Destroy() end
game.ReplicatedStorage.Sword:WaitForChild("EnemyHit").OnServerEvent:Connect(Damage)
Closed as Too Broad by User#24403
This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.
Why was this question closed?