Hello Everyone! I’m making right now Puzzle game and I have question how to make Character Switcher.
-
What do you want to achieve? I want to make character chooser. for example I have 3 raccoons and I want to make so player can switch raccoons, and if player choosed Raccoon 2 when he is on Raccoon 1, then it’s saving position of Raccoon 1.
-
What is the issue? I’ve already made first version of it, but I have a lot of bugs, for example in LocalScript I have raccoonPlaying local, and I have checker that checks if player already playing on this Raccoon, but it’s not changing at all. And I have second bug that it’s not saving raccoons position in table.
-
What solutions have you tried so far? I didn’t find any solutions and no one asking about it, or maybe asking but I didn’t find.
Server Script:
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.Events.Chooser
remote.OnServerEvent:Connect(function(plr,char,cf)
local newChar = rs.Characters[char]:Clone()
if game.StarterPlayer:FindFirstChild("StarterCharacter") then
game.StarterPlayer.StarterCharacter:Destroy()
end
newChar.HumanoidRootPart.Anchored = false
newChar.Name = "StarterCharacter"
newChar.Parent = game.StarterPlayer
plr:LoadCharacter()
newChar.PrimaryPart.CFrame = cf
end)
Local Script:
local raccoonPos = {
["1"] = CFrame.new(13.348, 2.35, -13.243),
["2"] = CFrame.new(-29.027, 2.35, -1.142)
}
local raccoonPlaying = 1
local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local rs = game:GetService("ReplicatedStorage")
local characters, remote = rs.Characters, rs.Remotes.Events.Chooser
local btns = script.Parent
btns["1"].Activated:Connect(function()
if raccoonPlaying == 1 then
warn("Already choosed!")
else
raccoonPlaying = 1
raccoonPos["2"] = char.PrimaryPart.CFrame
remote:FireServer("Raccoon1", raccoonPos["1"])
end
end)
btns["2"].Activated:Connect(function()
if raccoonPlaying == 2 then
warn("Already choosed!")
else
raccoonPlaying = 2
raccoonPos["1"] = char.PrimaryPart.CFrame
remote:FireServer("Raccoon2", raccoonPos["2"])
end
end)
I don’t have any errors in output, so if someone can help, that would be really appreciated! Thanks.