Hello im making this game where theres a purchase to fog the whole server so that players cant see (
the problem is I need to add a message for all the players so that they can get announced
after scripting the message script I have added a event now,
im using a server script for the purchase
but when I fire the event
the messages double every time and even if I print something it doubles the print everytime it like the event doubles more and more every time I fire it
--- Made by Yqta (Alt)
----- Services -----
local Services = {
Players = game:GetService("Players"),
TS = game:GetService("TweenService"),
}
----- Remotes -----
local RepHolder = game.ReplicatedStorage.ReplicatedStorageHolder
local Remotes = RepHolder.Remotes
local OurRem = Remotes.ServerEvents.Message
-----
function CreateAnnouncement(Text, _Delay, _Color3)
local List = script.Parent.AnnouncementList
local Slot = script.AnnouncementSlot:Clone()
Slot.TextLabel.TextColor3 = _Color3 or Color3.fromRGB(255,255,255)
Slot.Drop.TextColor3 = _Color3 or Color3.fromRGB(255,255,255)
Slot.Name = "AnnounceText"
Slot.Parent = List
print("aNNOUNCE")
for i = 1, #Text do
Slot.TextLabel.Text = string.sub(Text, 1, i)
Slot.TransparentDrop.Text = Slot.TextLabel.Text
Slot.Drop.Text = Slot.TextLabel.Text
wait()
end
wait(_Delay or 5)
for i = #Text, 0, -1 do
local v = ""
if i == 0 then
v = ""
else
v = string.sub(Text, 1, i)
end
Slot.TextLabel.Text = v
Slot.TransparentDrop.Text = Slot.TextLabel.Text
Slot.Drop.Text = Slot.TextLabel.Text
if i % 3 == 0 then
wait()
end
end
Slot.TextLabel.Text = ""
Slot.TransparentDrop.Text = Slot.TextLabel.Text
Slot.Drop.Text = Slot.TextLabel.Text
Slot:Destroy()
end
function CreateMessage(Text, _Delay)
local Slot = script.MessageSlot:Clone()
Slot.TextLabel.Text = Text
Slot.Name = "Message"
Slot.Parent = script.Parent
local Waittime = 0.5
local Tinfo = TweenInfo.new(Waittime, Enum.EasingStyle.Linear)
Slot.TextLabel.TextTransparency = 0
Slot.TextLabel.TextStrokeTransparency = 0
wait(_Delay or 4)
Services.TS:Create(Slot.TextLabel, Tinfo, {TextTransparency = 1}):Play()
Services.TS:Create(Slot.TextLabel, Tinfo, {TextStrokeTransparency = 1}):Play()
wait(Waittime)
Slot.TextLabel.Text = ""
Slot:Destroy()
end
script.Parent.CreateMessage.Event:Connect(function(isAnn, Text, _Delay, _Color3)
if isAnn then
print("v")
CreateAnnouncement(Text, _Delay, _Color3)
else
print("v")
CreateMessage(Text, _Delay)
end
end)
OurRem.OnClientEvent:Connect(function( isAnn, _Delay, Text, _Color3)
if isAnn then
print("w")
CreateAnnouncement(Text, _Delay, _Color3)
else
CreateMessage(Text, _Delay)
end
end)
Fog = function(PlayerBought)
print("Script without checking plate")
if PlayerBought then
print("SOME")
local FogFolder = self.Purchases.Fog
self.ProductExtraTimes.Fog += 1
if self.ProductExtraTimes.Fog >= 2 then
print("extended")
workspace:FindFirstChild("GLOBAL_SOUNDS").TimerExtend:Play()
FogFolder.CountdownRemaining.Value+= FogFolder.Countdown.Value
for i,Player in pairs(game.Players:GetChildren()) do
self.ServerRemotes:WaitForChild("ServerEvents").Message:FireClient(Player,true,4,string.upper(PlayerBought.Name.." Has extended fog"),Color3.new(255,255,255))
end
else
FogFolder.CountdownRemaining.Value = FogFolder.Countdown.Value
self.ServerRemotes.ServerEvents.Message:FireAllClients(true,4,string.upper(PlayerBought.Name.." Has activated fog"),Color3.new(255,255,255))
workspace:FindFirstChild("GLOBAL_SOUNDS").FoggyOn:Play()
game:GetService("TweenService"):Create(game.Lighting:FindFirstChild("Atmosphere"),TweenInfo.new(2,Enum.EasingStyle.Linear),{Density = 0.7}):Play()
while wait(1) do
if FogFolder.CountdownRemaining .Value ~= 0 then
FogFolder.CountdownRemaining.Value -= 1
else
workspace:FindFirstChild("GLOBAL_SOUNDS").FoggyOff:Play()
game:GetService("TweenService"):Create(game.Lighting:FindFirstChild("Atmosphere"),TweenInfo.new(2,Enum.EasingStyle.Linear),{Density = 0}):Play()
break
end
end
end
end
end,
the message script is a local script and the script I fire it from it is a server script
Please do not ask people to write entire scripts or design entire systems for you. If you canβt answer the three questions above, you should probably pick a different category.