Script wont delete when needed (Using TopBarPlus)

I’m working on a character selector for my Fist of the North Star fighting game, and I’m having trouble making it so the dash script for each character is deleted when you switch from each character. The combat scripts work just fine, they get traded and deleted without issue; but the script for the dash stays regardless of what character you pick.

I’ve tried putting the InputManager scripts (the scripts with the dash) inside the combat scripts, but that just breaks the dash. I am stumped here, and i cant progress with development if i let this bug persist.

If its important, this is the first time ive ever made a game. I have followed a few tutorials online and i cant seem to crack why its working for the combat but not the dash.

Character select script below


local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

local container  = script.Parent
local Icon = require(container.Icon)
local kenshirop = false
local testp = false
local reip = false

Icon.new()
	:setName("Characters")
	:setLabel("Characters")
	:setImage(108016607962951)
	:bindEvent("selected", function()
	end) 
	:setDropdown({
		
		Icon.new()
		:setName("Apoclyptic Savior")
		:setLabel("Apoclyptic Savior")
		:setImage(75135816279518)
		:bindEvent("selected", function()
			if kenshirop == false then
				kenshirop = true
				reip = false
				
				game.ReplicatedStorage.MainEvent:FireServer("Kill")
				
				if plr.PlayerScripts:FindFirstChild("ReiCombatClient") then
					plr.PlayerScripts.ReiCombatClient:Destroy()
				end
				if plr.PlayerScripts:FindFirstChild("ReiInputManager") then
					plr.PlayerScripts.ReiInputManager:Destroy()
				end
				
				local ClientScript = game.ReplicatedStorage:WaitForChild("Scripts"):WaitForChild("KenshiroCombatClient"):Clone()
				ClientScript.Parent = plr.PlayerScripts
				local ClientScript2 = game.ReplicatedStorage:WaitForChild("Scripts"):WaitForChild("KenshiroInuptManager"):Clone()
				ClientScript2.Parent = plr.PlayerScripts
			
				
				
			end
		end)
		,
		Icon.new()
		:setName("Rei")
		:setLabel("White Water Bird")
		:setImage(75135816279518)
		:bindEvent("selected", function()
			if reip == false then
				reip = true
				kenshirop = false
		
				game.ReplicatedStorage.MainEvent:FireServer("Kill")
				
				if plr.PlayerScripts:FindFirstChild("KenshiroCombatClient") then
					plr.PlayerScripts.KenshiroCombatClient:Destroy()
				end
				if plr.PlayerScripts:FindFirstChild("KenshiroInputManager") then
					plr.PlayerScripts.KenshiroInputManager:Destroy()	
				end
				
				local ClientScript = game.ReplicatedStorage:WaitForChild("Scripts"):WaitForChild("ReiCombatClient"):Clone()
				ClientScript.Parent = plr.PlayerScripts
				local ClientScript2 = game.ReplicatedStorage:WaitForChild("Scripts"):WaitForChild("ReiInuptManager"):Clone()
				ClientScript2.Parent = plr.PlayerScripts
			end
		end) 
		
	})

Video of this bug, incase it helps in any way. Thank you in advance!

Bumping, still unsolved. Please help me!

you shouldn’t switch scripts, your script should switch behaviour

Switch behaviour? How would i go about doing that?

constants, if statements, each character has configuration, for example CHARACTER_RED_DASH_DISTANCE, and etc, apply specific constants, configurations based on current character

The error occurs because the code calls an invalid script name.
In ReplicatedStorage, the script is named “KenshiroInuptManager”, “RelInuptManager”, but in the code you are trying to remove “KenshiroInputManager”, “RelInputManager”
As a result, the FindFirstChild() function returns nil, and the script is not deleted.

1 Like

Oh my god thats embarrassing
Thank you though, i was struggling so hard to fix this andit was 2 letters under my nose this whole time qwq

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.