I also usually get this issue on my scripts and the way that i fixed it by adding a boolean to check if the remoteEvent fired, it’s something similar like
Custom.Activated:Connect(function()
local fired = false
if DB == false then
print(DB)
DB = true
if fired == false then
CharEdit:Fire()
fired = true
end
print("fired")
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = Cams.CharEdit.CFrame
end
end)
Which could probably fix the issue that you’re having
Those are all scripts that use it. None are duplicates
All use the function, but do different things, I just checked.
I also did the check before the event fires.
print("ey homeboy")
local fired = false
if DB == false then
print(DB)
DB = true
if fired == false then
CharEdit:Fire()
fired = true
end
print("fired")
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = Cams.CharEdit.CFrame
end
end)
local Teams = script.Parent
local Human = Teams.Human
local Vamp = Teams.Vamp
local Wolf = Teams.Wolf
local Custom = Teams.Customizer
local Cams = game.Workspace.Cameras
local Cam = game.Workspace.Camera
local TeamSetter = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("SetTeam")
local CloseEvent = game.ReplicatedStorage.Events:WaitForChild("CloseTitle")
local Loaded = game.ReplicatedStorage.Events:WaitForChild("LoadedIn")
local CharEdit = game.ReplicatedStorage.Events:WaitForChild("CharEdit")
local cas = game:GetService("ContextActionService")
local plr = game:GetService("Players").LocalPlayer
local playerGui = plr:WaitForChild("PlayerGui")
local char = plr.Character
local Title = playerGui:WaitForChild("Title")
local DB = false
local blur = require(game.Lighting.Blur.Animator)
local tran = require(game.Lighting.Transition.Animator)
local function transition()
blur.Transition:Play()
tran.Transition:Play()
end
plr.CharacterAdded:Connect(function()
print("DB exists")
DB = false
char = plr.Character
TeamSetter:FireServer("Spirits")
cas:BindActionAtPriority("DisableControls",function()
return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.High.Value, unpack(Enum.PlayerActions:GetEnumItems()))
print("freeze")
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = Cams.Human.CFrame
Title.Enabled = true
end)
Human.MouseEnter:Connect(function()
print("e")
if DB == false then
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = Cams.Human.CFrame
transition()
end
end)
Human.Activated:Connect(function()
print("the internal screaming is real")
if DB == false then
DB = true
TeamSetter:FireServer("Humans", Cams.Human)
Cam.CameraType = Enum.CameraType.Custom
Cam.CameraSubject = char.Humanoid
CloseEvent:Fire()
cas:UnbindAction("DisableControls")
end
end)
Vamp.MouseEnter:Connect(function()
print("i think this might be roblox's fault")
if DB == false then
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = Cams.Vampire.CFrame
transition()
end
end)
Vamp.Activated:Connect(function()
print("help")
if DB == false then
DB = true
TeamSetter:FireServer("Vampires", Cams.Vampire)
Cam.CameraType = Enum.CameraType.Custom
Cam.CameraSubject = char.Humanoid
CloseEvent:Fire()
cas:UnbindAction("DisableControls")
end
end)
Wolf.MouseEnter:Connect(function()
print("hey guys, it's markiplier")
if DB == false then
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = Cams.Werewolf.CFrame
transition()
end
end)
Wolf.Activated:Connect(function()
print("heloo")
if DB == false then
DB = true
TeamSetter:FireServer("Werewolves", Cams.Werewolf)
Cam.CameraType = Enum.CameraType.Custom
Cam.CameraSubject = char.Humanoid
CloseEvent:Fire()
cas:UnbindAction("DisableControls")
end
end)
Custom.Activated:Connect(function()
print("ey homeboy")
local fired = false
if DB == false then
print(DB)
DB = true
if fired == false then
CharEdit:Fire()
fired = true
end
print("fired")
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = Cams.CharEdit.CFrame
end
end)
Loaded.Event:Connect(function()
DB = false
end)
Custom.Activated:Connect(function()
print("ey homeboy")
local fired = false
if DB == false then
print(DB)
DB = true
if fired == false then
CharEdit:Fire("Custom.Activated")
fired = true
end
print("fired")
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = Cams.CharEdit.CFrame
end
end)
At this point, and for a lack of a better term, I am bamboozled, it looks like the function fires twice, even though the code fires it once, you might want to consider putting this topic to #bug-reports:studio-bugs.
I would, but unfortunately I don’t have access to making topics in bug reports… I joined after they closed the program that let devs get access to it. I’ll try flagging for a category change, though it’s unlikely to work.
I should mention, this all started happening after deleting Rojo (it was clogging up script analysis). I don’t know if that caused it. I’ll reinstall studio.
From the icon in this image, it appears that you are using Scripts with the RunContext set to Client. This means that they can run anywhere, even in StarterGui. The contents of StarterGui always exist, and they are cloned to the client’s PlayerGui upon loading into the game (or respawning, if the child is not a LayerCollector or has ResetOnSpawn enabled). Normally, this would not matter, as LocalScripts do not run in StarterGui. However, RunContext allows the Script to run anywhere, meaning that two copies of the script are running, one in StarterGui and one in the PlayerGui.
To get around this, you should always use LocalScripts in all ‘Starter’ containers, which is the recommended option in the announcement for RunContext.
Hmm… it seems like multiple copies of the script are running, especially with the changes you made to it. Could you try running this code and see what the output is? If only one script is running, the randomly generated number will be the same, but if multiple are running, it will be different.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LoadedIn = ReplicatedStorage:WaitForChild("Events"):WaitForChild("LoadedIn")
local CloseEvent = ReplicatedStorage.Events:WaitForChild("CloseTitle")
local SetFake = ReplicatedStorage.Events:WaitForChild("SetFake")
local Players = game.Players
local Player = Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Title = PlayerGui:WaitForChild("CharCustom")
local Frame = Title:WaitForChild("Frame")
local UIGradient = Frame:WaitForChild("UIGradient")
local AniModule = require(UIGradient:WaitForChild("Animator"))
local FadeIn = AniModule.FadeIn
local FadeOut = AniModule.FadeOut
local In = false
local CharEdit = ReplicatedStorage.Events:WaitForChild("CharEdit")
local ClientMaps = ReplicatedStorage:WaitForChild("ClientMaps")
local Room = ClientMaps:WaitForChild("CustomEditor")
local Workspace = game.Workspace
local part = Workspace.SpawnLocation
local fakeChar
local randomNumberTest = math.random()
CharEdit.Event:Connect(function(tthing)
if fakeChar ~= true then
print("AAAAA", randomNumberTest)
print(tthing)
Room.Parent = game.Workspace
Title.Enabled = true
FadeIn:Play()
In = true
Room.Parent = game.Workspace
Player.Character.Archivable = true
fakeChar = Player.Character:Clone()
fakeChar.HumanoidRootPart.Position = Vector3.new(-587.5, 62.656, -84)
fakeChar.HumanoidRootPart.Orientation = Vector3.new(0, -90, -0)
fakeChar.Parent = game.Workspace
fakeChar.Name = "FakeChar"
Player.Character.Archivable = false
SetFake:Fire(fakeChar)
fakeChar = true
end
end)
LoadedIn.Event:Connect(function()
FadeOut:Play()
task.wait(1.5)
Title.Enabled = false
Room.Parent = game.ReplicatedStorage.ClientMaps
fakeChar = false
end)
I fixed it. I had to wrap the entire script into an if statement, to make sure it wouldn’t do anything in StarterGui.
if script.Parent.Parent ~= game:GetService("StarterGui") then
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LoadedIn = ReplicatedStorage:WaitForChild("Events"):WaitForChild("LoadedIn")
local CloseEvent = ReplicatedStorage.Events:WaitForChild("CloseTitle")
local SetFake = ReplicatedStorage.Events:WaitForChild("SetFake")
local Players = game.Players
local Player = Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Title = PlayerGui:WaitForChild("CharCustom")
local Frame = Title:WaitForChild("Frame")
local UIGradient = Frame:WaitForChild("UIGradient")
local AniModule = require(UIGradient:WaitForChild("Animator"))
local FadeIn = AniModule.FadeIn
local FadeOut = AniModule.FadeOut
local In = false
local CharEdit = ReplicatedStorage.Events:WaitForChild("CharEdit")
local ClientMaps = ReplicatedStorage:WaitForChild("ClientMaps")
local Room = ClientMaps:WaitForChild("CustomEditor")
local Workspace = game.Workspace
local part = Workspace.SpawnLocation
local fakeChar
local randomNumberTest = math.random()
CharEdit.Event:Connect(function(tthing)
if fakeChar ~= true then
print("AAAAA", randomNumberTest)
print(tthing)
Room.Parent = game.Workspace
Title.Enabled = true
FadeIn:Play()
In = true
Room.Parent = game.Workspace
Player.Character.Archivable = true
fakeChar = Player.Character:Clone()
fakeChar.HumanoidRootPart.Position = Vector3.new(-587.5, 62.656, -84)
fakeChar.HumanoidRootPart.Orientation = Vector3.new(0, -90, -0)
fakeChar.Parent = game.Workspace
fakeChar.Name = "FakeChar"
Player.Character.Archivable = false
SetFake:Fire(fakeChar)
fakeChar = true
end
end)
LoadedIn.Event:Connect(function()
FadeOut:Play()
task.wait(1.5)
Title.Enabled = false
Room.Parent = game.ReplicatedStorage.ClientMaps
fakeChar = false
end)
end