I need some help, whenever I select back to the original character, it returns me back to the chosen one…
Let’s say I have “Nooby” as default, I change to “Dummy” and it works just fine, I select nooby once more, I do get his stuff but Dummy’s aswell!
I tried multiple things to solve this, none of them work… maybe is there someone that already figured this out? I searched for a similar problem on the forum and found none. Am I just dumb or I encountered a bug. I don’t even know at this point.
Gui script
local sPlayers = game:GetService("Players")
local sReplicated = game:GetService("ReplicatedStorage")
local charChange = sReplicated.ChangePlayerCharacter
local player = sPlayers.LocalPlayer
local TopBarMod = require(game.ReplicatedStorage:WaitForChild('Icon'))
local function SetChar(char)
local character = player.Character or player.CharacterAdded:Wait()
local chosenCharacter = character:WaitForChild("Character")
if chosenCharacter.Value == char then return end
charChange:FireServer(char)
end
local AdminButton = TopBarMod.new()
:setLabel("Dummy")
:bindEvent("selected", function(icon)
SetChar("Dummy")
icon:deselect()
end)
local NoobyButton = TopBarMod.new()
:setLabel("Nooby")
:bindEvent("selected", function(icon)
SetChar("Nooby")
icon:deselect()
end)
Server script (it changes the character of course)
local replicated = game.ReplicatedStorage
local charChange = replicated.ChangePlayerCharacter
local players = game.Players
charChange.OnServerEvent:Connect(function(plr, char)
local plrChar = plr.Character
plrChar:BreakJoints()
plr.CharacterAdded:Connect(function(character)
local characterVal = character:WaitForChild("Character")
characterVal.Value = char
local charMoveset = game.ServerStorage:FindFirstChild(char):Clone()
for _,move in charMoveset:GetChildren() do
move.Parent = plr.Backpack
end
end)
end)
Output log
18:29:25.812 Dummy - Server - CharacterChangeHandler:12
18:29:29.495 Nooby - Server - CharacterChangeHandler:12
18:29:29.495 Dummy - Server - CharacterChangeHandler:12
While having “Nooby”, as default