Why is the Tablet not correctly CFraming?
Tablets={}
function Tablet(Colr,Txt,Plr)
local TabModel=Instance.new('Model',workspace)
local Tab=Instance.new('Part',TabModel)
Tab.Anchored=true
Tab.Locked=true
Tab.CanCollide=false
Tab.FormFactor=('Custom')
Tab.Size=Vector3.new(4,5,0.2)
Tab.BrickColor=BrickColor.new(Colr)
Tab.Transparency=0.3
local Click=Instance.new('ClickDetector',Tab)
Click.MaxActivationDistance=math.huge
Click.MouseClick:connect(function(Pl) if Plr==Plr then Tab:Destroy()
----------------------------------
end
end)
table.insert(Tablets,TabModel)
end
local starttime = tick()
game:GetService("RunService").Heartbeat:connect(function()
ypcall(function()
for _,Player in pairs(game.Players:GetPlayers()) do
local PlayerTablets = {}
for i,v in pairs(Tablets) do
if v.TabModel.Parent ~= nil and v.Tab.Parent ~= nil and v.Plr == Player.Name then
table.insert(PlayerTablets, v)
end
end
for i = 1, #PlayerTablets do
ypcall(function()
local tab = PlayerTablets[i].Tab
local pos = nil
ypcall(function()
pos = Player.Character.Head.CFrame
end)
local x = math.sin(time()/#PlayerTablets + (math.pi*2)/#PlayerTablets*i) * (#PlayerTablets+6)
local z = math.cos(time()/#PlayerTablets + (math.pi*2)/#PlayerTablets*i) * (#PlayerTablets+6)
local cPos = tab.Position
local ePos = Vector3.new(x, 0, z) + (pos.p or Vector3.new(0, -5, 0))
local nPos = (ePos-cPos)*.25
cPos = cPos + nPos
local t = (tick() - starttime) % 360
local change = 0.625
PlayerTablets[i].Size = math.sin(t) * change + 2.375
tab.CFrame = CFrame.new(cPos,cPos,cPos)
tab.CFrame = CFrame.new(cPos, (pos.p or Vector3.new(0, -5, 0))) * CFrame.Angles(math.rad(11.25), 0, 0)
end)
end
end
end)
end)
wait(5)
for _, Plr in pairs(game.Players:GetPlayers()) do
Tablet('Lime green','TESTING TABLET ROT' or tostring(error),Plr)
end