Today, I’m trying to make a working voting system. Once the players finishes voting they will spawn in the map.
The issue is that when the LocalScript activates “LoadPlayer” function, the camera doesn’t lock into the character of the player even though the CameraType was set to custom.
I tried setting the CameraType in testing and found out that the game is automatedly setting the Camera Type to Scriptable when I tried to change it. There are no scripts in the game that is changing the Camera Type to Scriptable in a loop so it couldn’t be the case.
Any help is appreciated!
local Frame = script.Parent
local Status = Frame.Parent:WaitForChild("Timer")
local GUI = Frame.Parent.Parent
local RS = game:GetService("ReplicatedStorage")
local TimeValue = RS:WaitForChild("VoteTime")
local MapEvent = RS:WaitForChild("MakeMap")
local VoteFolder = RS:WaitForChild("Votes")
local AssignTeam = RS:WaitForChild(",,.><l.io2h^%Htdegy^Y&HNNJY ^m^464RUYj7uyi75i65=-0-=-0po0-jpio7654cyvjukikjtdv67v6jvj j vv vj v v kv")
local DoneVoting = false
local Player = game:GetService("Players").LocalPlayer
local HealthBar = Frame.Parent.Parent.Parent:WaitForChild("HealthBar")
local MobileShiftLock = Frame.Parent.Parent.Parent:WaitForChild("MoblieShiftLock")
local EnergyBar = Frame.Parent.Parent.Parent:WaitForChild("EnergyBar")
local Inventory = Frame.Parent.Parent.Parent:WaitForChild("BackpackGUI")
local CardsSytem = Frame.Parent.Parent.Parent:WaitForChild("EventCards")
function GetChosen()
local PlaceVotes = {
["Kings Hills"] = VoteFolder['Kings Hills'].Value,
["Golden Desert"] = VoteFolder['Golden Desert'].Value,
}
local Highest = 0
local Place = nil
for i,votes in pairs(PlaceVotes) do
if votes > Highest then
Highest = votes
Place = i
print(i)
end
end
return Place
end
function LoadPlayer()
local Cam = workspace.CurrentCamera
Cam.CameraType = Enum.CameraType.Custom
Cam.HeadLocked = true
print("Head Locked")
AssignTeam:FireServer(Player)
local HealthScript = HealthBar:WaitForChild("Health")
local EnergyScript = EnergyBar:WaitForChild("Energy")
Theme:Stop()
HealthBar.Enabled = true
EnergyBar.Enabled = true
MobileShiftLock.Enabled = true
Inventory.Enabled = true
CardsSytem.Enabled = true
HealthScript.Disabled = false
EnergyScript.Disabled = false
GUI.Enabled = false
end
function StartTimer()
for i = 20, 0, -1 do
wait(1)
print(i)
TimeValue.Value = i
Status.Text = TimeValue.Value
end
print("Time Done")
local ChosenPlace = GetChosen()
if ChosenPlace == nil then
Status.Text = "It was a Tie! Vote again!"
wait(1)
StartTimer()
else
Status.Text = ChosenPlace.." got the most votes!"
wait(3)
Status.Text = "Loading Game..."
MapEvent:InvokeServer(ChosenPlace)
wait(5)
LoadPlayer()
end
end
GUI.Changed:Connect(function(obj)
if obj == "Enabled" and GUI.Enabled == true then
StartTimer()
end
end)