but it broke whenever i did a normal round, but it works perfectly fine when debugging
the gui resetonspawn is set to true
local char = game.Players.LocalPlayer.Character
if char then
print("char found")
else
game.Players.LocalPlayer.CharacterAdded:Wait()
end
print("YAH")
repeat task.wait() until game.Players.LocalPlayer.Character.Parent == workspace.Killers or game.Players.LocalPlayer.Character.Parent == workspace.Survivors
if game.Players.LocalPlayer.Character.Parent == workspace.Killers then
print("YAHHH")
for i, v in pairs(workspace.Survivors:GetChildren()) do
if v:IsA("Model") then
if v:WaitForChild("Humanoid") and v.PrimaryPart ~= nil then
local OLDHP = v:WaitForChild('Humanoid').Health
game:GetService("RunService").Heartbeat:Connect(function()
print("yes")
local HP = v:WaitForChild("Humanoid").Health
if HP < OLDHP then
local damage = OLDHP - HP
OLDHP = HP
if damage > 5 then
local template = script.Parent.MiBoard:Clone()
template.Name = "ttt"
template.Adornee = v.PrimaryPart
template.Parent = script.Parent
template.Enabled = true
template.MiText.Text = damage
script.Parent.Parent.Parent["Hit sound"]:Play()
print("yes")
repeat
template.MiText.TextTransparency += 0.1
template.MiText.UIStroke.Transparency += 0.1
template.StudsOffset += Vector3.new(0,-0.1,0)
task.wait(0.1)
until template.MiText.TextTransparency > 0.9
template:Destroy()
end
end
end)
end
end
end
workspace.Survivors.ChildAdded:Connect(function(v)
if v:IsA("Model") then
if v:WaitForChild("Humanoid") and v.PrimaryPart ~= nil then
local OLDHP = v:WaitForChild('Humanoid').Health
game:GetService("RunService").Heartbeat:Connect(function()
print("yes")
local HP = v:WaitForChild("Humanoid").Health
if HP < OLDHP then
local damage = OLDHP - HP
OLDHP = HP
if damage > 5 then
local template = script.Parent.MiBoard:Clone()
template.Name = "ttt"
template.Adornee = v.PrimaryPart
template.Parent = script.Parent
template.Enabled = true
template.MiText.Text = damage
script.Parent.Parent.Parent["Hit sound"]:Play()
repeat
template.MiText.TextTransparency += 0.1
template.MiText.UIStroke.Transparency += 0.1
template.StudsOffset += Vector3.new(0,-0.1,0)
task.wait(0.1)
until template.MiText.TextTransparency > 0.9
template:Destroy()
end
end
end)
end
end
end)
local v = game.Players.LocalPlayer.Character
if v:WaitForChild("Humanoid") and v.PrimaryPart ~= nil then
local OLDHP = v:WaitForChild('Humanoid').Health
game:GetService("RunService").Heartbeat:Connect(function()
local HP = v:WaitForChild("Humanoid").Health
if HP < OLDHP then
local damage = OLDHP - HP
if damage > 5 then
game.ReplicatedStorage.HitSoundServer:FireServer(v,OLDHP,HP)
OLDHP = HP
end
end
end)
end
end
if game.Players.LocalPlayer.Character.Parent == workspace.Survivors or game.Players.LocalPlayer.Character.Parent == workspace.Killers then
print('YAHG')
game.ReplicatedStorage.HitSound.OnClientEvent:Connect(function(v,old,hp)
print(old,hp,v)
if v:WaitForChild("Humanoid") and v.PrimaryPart ~= nil then
local OLDHP = old
local HP = hp
if HP < OLDHP then
print(HP,OLDHP)
local damage = OLDHP - HP
OLDHP = HP
if damage > 5 then
local template = script.Parent.MiBoard:Clone()
template.Name = "ttt"
template.Adornee = v.PrimaryPart
template.Parent = script.Parent
template.Enabled = true
template.MiText.Text = damage
script.Parent.Parent.Parent["Hit sound"]:Play()
print("yes")
repeat
template.MiText.TextTransparency += 0.1
template.MiText.UIStroke.Transparency += 0.1
template.StudsOffset += Vector3.new(0,-0.1,0)
task.wait(0.1)
until template.MiText.TextTransparency > 0.9
template:Destroy()
end
end
end
end)
end
server:
game.ReplicatedStorage.HitSoundServer.OnServerEvent:Connect(function(pl,v,old,hp)
if v then
game.ReplicatedStorage.HitSound:FireAllClients(v,old,hp)
end
end)
Should run better than ever or not at all.
Tried to stick with your style..
Modifications Version 2
local plr = game.Players.LocalPlayer
local rep = game:GetService("ReplicatedStorage")
local char = plr.Character or plr.CharacterAdded:Wait()
repeat task.wait() until char.Parent == workspace.Characters.Killers or char.Parent == workspace.Characters.Survivors
local group = char.Parent
local targetFolder = group == workspace.Characters.Killers and workspace.Characters.Survivors or workspace.Characters.Killers
local function showDamage(v, dmg)
local g = script.Parent.MiBoard:Clone()
g.Adornee = v.PrimaryPart
g.Parent = script.Parent
g.Enabled = true
g.MiText.Text = dmg
script.Parent.Parent.Parent["Hit sound"]:Play()
repeat
g.MiText.TextTransparency += 0.1
g.MiText.UIStroke.Transparency += 0.1
g.StudsOffset += Vector3.new(0, -0.1, 0)
task.wait(0.1)
until g.MiText.TextTransparency > 0.9
g:Destroy()
end
local function bind(v)
local hum = v:WaitForChild("Humanoid")
local old = hum.Health
hum.HealthChanged:Connect(function(hp)
if hp < old then
local dmg = old - hp
if dmg > 5 then
if group == workspace.Characters.Killers then
showDamage(v, dmg)
else
rep.HitSoundServer:FireServer(v, old, hp)
end
end
end
old = hp
end)
end
local function bindAll()
for _, v in ipairs(targetFolder:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("Humanoid") and v.PrimaryPart then
bind(v)
end
end
end
targetFolder.ChildAdded:Connect(function(v)
if v:IsA("Model") and v:FindFirstChild("Humanoid") and v.PrimaryPart then
bind(v)
end
end)
rep.HitSound.OnClientEvent:Connect(function(v, old, hp)
if v and v:FindFirstChild("Humanoid") and v.PrimaryPart then
local dmg = old - hp
if dmg > 5 then showDamage(v, dmg) end
end
end)
plr.CharacterAdded:Connect(function(newChar)
char = newChar
repeat task.wait() until char:FindFirstChild("Humanoid")
bindAll()
end)
bindAll()
local rep = game:GetService("ReplicatedStorage")
rep.HitSoundServer.OnServerEvent:Connect(function(plr, v, old, hp)
if v and v:FindFirstChild("Humanoid") then
rep.HitSound:FireAllClients(v, old, hp)
end
end)
so i added prints into the script and none of them fired
local function bind(v)
local hum = v:WaitForChild("Humanoid")
local old = hum.Health
hum.HealthChanged:Connect(function(hp)
print("yes")
if hp < old then
local dmg = old - hp
print("yes2")
if dmg > 5 then
if group == workspace.Killers then
showDamage(v, dmg)
print("yes3")
else
rep.HitSoundServer:FireServer(v, old, hp)
print("yes4")
end
end
end
old = hp
end)
end
I am not 100% sure what it is you’re trying to do. Perhaps you could give more detail? For example, show the video of your system working on rigs.
But I think you’re trying to display the damage the player took. Here’s a simpler approach.
Create a local script and parent it to startercharacterscripts.
local Players = game:GetService(“Players”)
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild(“PlayerGui”)
local HitGui = PlayerGui:WaitForChild(“HitNumber”)
local HitNumbers = HitGui:WaitForChild(“[Hit Numbers”])
local MiBoard = HitNumbers:WaitForChild(“MiBoard”)
local MiText = MiBoard:WaitForChild(“MiText”)
local character = script.Parent
local humanoid = character:WaitForChild(“Humanoid”)
local MaxHealth = humanoid.MaxHealth
humanoid.HealthChanged:Connect(function()
local HP = humanoid.Health
local damage = MaxHealth - HP
MiText.Text = damage
end)
Important thing to note if you want your game to work, you should really look into optimisation and cleaning up your code for readability.
Optimizing your game is really important especially in your case. Because from what I’m seeing you seem to be a new/inexperienced scripter. the code in your game has a high chance of causing players to have slow buggy experiences or even crash.
For example, you’ve a lot of potential memory leaks in your current code. And I’m assuming you write your server-sided code in the same manner.
You’re also unnecessarily using heartbeat events, constant running code like while loops and run service events can be expensive on resources.
Learn about memory leaks and performance optimisation in general so that your players will have a smooth experience. Lucky for you, your game isn’t too popular so that’s why atleast for now a lot of players might not be experiencing problems.
Edit: OP I played your game on my iPhone 13 which is quite new and is one of the most optimised iPhones. And I crashed within 2 minutes, this is really concerning if it’s happening on newer models of the iPhone so quickly. there are big problems in your game that need fixing.
It’s not about it working, it’s about your code not destroying the player’s experience overtime.
Not just the humanoid.HealthChanged event that you connect each time the bind function is ran. Look at the workspace.Survivors.ChildAdded event. Each time that is ran new runservice events are set up and that can take a toll on resources and memory.
You should really look into the stuff I linked because your game just isn’t ready yet.