im trying to make killstreak system on my roblox game
and it works perfectly fine
but theres one little tiny problem
idk how i can make it display a ui when someone having 5 killstreaks, 10, or even 20
i have tried using the remote event with :FireAllClients() function but it didnt work
how can i make this???
thx,
NormalUser:)
1 Like
Tidyen
(Tidyen)
October 1, 2022, 4:39am
#2
You can use attributes to replicate a player’s killstreak with some attribute changed signals.
You’re not being very specific with what you have tried, FireAllClients will always send a signal to all clients, did you even set it up to properly receive the data from the event? Show us the script that you attempted to use.
script:
local streakEvent = game.ReplicatedStorage.Remotes.Events:WaitForChild("StreakEvent")
function streak(plr, streak, text)
streakEvent:FireAllClients(plr, streak, text)
end
game.Players.PlayerAdded:Connect(function(plr)
local values = Instance.new("Folder", plr)
values.Name = "values"
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local heads = Instance.new("IntConstrainedValue", values)
heads.Name = "Heads"
heads.MaxValue = 6
heads.Value = 0
local kills = Instance.new("NumberValue", leaderstats)
kills.Name = "Kills"
kills.Value = 0
local ks = Instance.new("NumberValue", leaderstats)
ks.Name = "Killstreak"
ks.Value = 0
local isInvisible = Instance.new("BoolValue", values)
isInvisible.Name = "Cloaking"
isInvisible.Value = false
local metals = Instance.new("IntConstrainedValue", values)
metals.Name = "Metals"
metals.MaxValue = 200
metals.Value = 200
plr.CharacterAdded:Connect(function(char)
local hum = char:FindFirstChild("Humanoid")
hum.Died:Connect(function()
plr.leaderstats:FindFirstChild("Killstreak").Value = 0
plr.values.Heads.Value = 0
local tag = hum:FindFirstChild("creator")
local killer = tag.Value
if tag and killer then
killer.leaderstats:FindFirstChild("Kills").Value += 1
killer.leaderstats:FindFirstChild("Killstreak").Value += 1
end
end)
end)
plr.leaderstats:FindFirstChild("Killstreak").Changed:Connect(function()
if plr.leaderstats:FindFirstChild("Killstreak").Value == 5 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 5 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 10 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 10 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 20 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 20 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 25 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 25 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 50 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 50 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 100 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 100 killstreak!")
end
end)
end)
local script:
local streakEvent = game.ReplicatedStorage.Remotes.Events:WaitForChild("StreakEvent")
local streakLabel = script.Parent.StreakLabel
streakEvent.OnClientEvent:Connect(function(plr, streak, streakText)
streakLabel.Text = streakText
end)
its pretty god damn messy, but here
The client does not get the player object. Remove that from the event and try it again.
I would like to note that you are repeating yourself a lot and you are firing this to all players. If you want it to only show the player their killstreak, then consider using :FireClient instead of FireAllClients
Disregard what I said about the player object, but you should not be using fire all clients when you are not at all using that player object.
KamuWasTaken:
f plr.leaderstats:FindFirstChild("Killstreak").Value == 5 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 5 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 10 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 10 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 20 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 20 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 25 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 25 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 50 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 50 killstreak!")
elseif plr.leaderstats:FindFirstChild("Killstreak").Value == 100 then
streak(plr, plr.leaderstats:FindFirstChild("Killstreak"), plr.DisplayName.."(@"..plr.Name..") is on 100 killstreak!")
You should not be repeating yourself so much, you are just wasting your own time by doing so.
You should make a variable like
local killStreakVal = plr.leaderstats:FindFirstChild("Killstreak").Value
Then you do not have to have plr.leaderstats:FindFirstChild(“Killstreak”).Value every single time.
1 Like
seancool07777:
I would like to note that you are repeating yourself a lot and you are firing this to all players. If you want it to only show the player their killstreak, then consider using :FireClient instead of FireAllClients
Disregard what I said about the player object, but you should not be using fire all clients when you are not at all using that player object.
what im trying to do is something like this post
I found this killstreak system in a game and I thought it would be a cool feature to add to my game to make it better, the only issue is I know nothing about scripting. Does anyone know how to make this or at least can direct me in the right direction to make this?
How it works: If someone gets a 5, 10, 15, 20, 25, so on, then it says “Username is on a # killstreak” and it will get put in the chat as if someone else typed a message just in a different format like the screenshot below.
[image]