I am making a system that when you join, you will become a camera man. But the problem is when morphing, the camera is always locked. Please help me solve this problem
Here’s the video about this and the system script:
robloxapp-20231201-1641030.wmv (3.6 MB)
local datastoreservice = game:GetService("DataStoreService")
local plrdata = datastoreservice:GetDataStore("plrdata")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local Coins = Instance.new("IntValue",leaderstats)
Coins.Name = "Coins"
local UsingCharacter = Instance.new("StringValue",plr)
UsingCharacter.Name = "UsingCharacter"
UsingCharacter.Value = "Camera Man"
local Characters = Instance.new("Folder",plr)
Characters.Name = "Character"
local Level = Instance.new("IntValue",leaderstats)
Level.Value = 1
Level.Name = "Level"
local Exp = Instance.new("IntValue",leaderstats)
Exp.Name = "Exp"
local ReqExp = Instance.new("IntValue",plr)
ReqExp.Name = "ReqExp"
ReqExp.Value = 3
local getdata = plrdata:GetAsync(plr.UserId)
if getdata then
Coins.Value = getdata[1]
UsingCharacter.Value = getdata[2]
Level.Value = getdata[4]
Exp.Value = getdata[5]
ReqExp.Value = getdata[6]
for _,char in pairs(getdata[3]) do
local newvalue = Instance.new("StringValue",Characters)
newvalue.Value = char
newvalue.Name = char
end
else
local cameraman = Instance.new("StringValue",Characters)
cameraman.Name = "Camera Man"
cameraman.Value = "Camera Man"
end
spawn(function()
while wait() do
if Exp.Value >= ReqExp.Value then
Exp.Value-=ReqExp.Value
Level.Value+=1
ReqExp*=1.2
end
end
end)
plr.CharacterAdded:Connect(function(oldchar)
if oldchar:FindFirstChild("Checker") == nil then
wait(1)
local newchar = game.ReplicatedStorage.Characters:FindFirstChild(UsingCharacter.Value):Clone()
newchar.Name = plr.Name
newchar.Parent = game.Workspace
plr.Character = newchar
newchar.PrimaryPart.CFrame = oldchar.PrimaryPart.CFrame
oldchar:Destroy()
end
end)
end)
local function onplrleft(plr)
local chars = {}
for _,char in pairs(plr.Characters:GetChildren()) do
if char.Name ~= "Value" then
table.insert(chars,char.Value)
end
end
plrdata:SetAsync(plr.UserId,{plr.leaderstats.Coins.Value,plr.UsingCharacter.Value,chars,plr.leaderstats.Level.Value,plr.leaderstats.Exp.Value,plr.ReqExp.Value})
end