Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with CFrame?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Im currently making a Tablet Admin its much more complex than most admins with guis and messages.

My rotation should make the "Tablet" move around the players Torso (like a orb) But the Rotation doesnt seem to want to find the current Tablet(s) make them CFrame to the current Torso.


Commands={} Tablets={} --MakeCommandInstance function Tablet(Colr,Txt,Plr) --This is "Tablet" (This is used to replace Guis/Messages) local Tab=Instance.new('Part',workspace) Tab.Name=('[Output]') Tab.Anchored=true Tab.Locked=true Tab.CanCollide=false Tab.FormFactor=('Custom') Tab.TopSurface=('SmoothNoOutlines') Tab.BottomSurface=('SmoothNoOutlines') Tab.Size=Vector3.new(4,5,0.2) Tab.BrickColor=BrickColor.new(Colr) Tab.Transparency=0.3 local Light=Instance.new('PointLight',Tab) Light.Color=Color3.new(Colr) local Box=Instance.new('SelectionBox',Tab) Box.Transparency=0.3 Box.Color=Tab.BrickColor Box.Adornee=Tab local g=Instance.new("BillboardGui",Tab) g.Adornee=Tab g.Active=false g.Size=UDim2.new(12,0,6) g.StudsOffset=Vector3.new(0,4,0) local l=Instance.new("TextLabel",g) l.Size=UDim2.new(1,0,1,0) l.BackgroundTransparency=1 l.TextColor3=Color3.new(0,0,0) l.TextStrokeColor3=Color3.new(Colr) l.TextStrokeTransparency=1 l.Font="SourceSansBold" l.TextWrapped=true l.TextColor3=Color3.new(255,255,255) l.Active=false l.FontSize="Size18" l.Text=Txt g.ExtentsOffset=Vector3.new(0,0,1) local Click=Instance.new('ClickDetector',Tab) Click.MaxActivationDistance=math.huge Click.MouseClick:connect(function(Pl) if Pl==Plr then return Tab:Destroy() end end) table.insert(Tablets, {Tab=Tab,Box=Box,txt=l}) end -- Now for the problem Im having its the rot or else this "Tablet" will just sit on the ground and do -----nothing -- Rotation! -- TabletRotation = 0 UpdateTablets = function() TabletRotation = TabletRotation==360 and 0 or TabletRotation + 0.0002 for _, Player in pairs(All()) do local PlrTabs = {} for i,v in pairs(Tablets) do if v.Tab.Parent ~= nil and v.Plr == Player.Name then table.insert(PlrTabs, v) end end for i,v in pairs(PlrTabs) do pcall(function() local pos = nil pcall(function() if Player.Character.Parent == workspace then pos = Player.Character.Torso.CFrame end end) if pos == nil then return end local radius = 8 + (#PlrTabs * 0.5) local x,y,z x = math.sin((i / #PlrTabs - (0.5 / #PlrTabs) * 2) * math.pi * 2) * radius y = 0 z = math.cos((i / #PlrTabs - (0.5 / #PlrTabs) * 2) * math.pi * 2) * radius local arot = Vector3.new(x,y,z)+pos.p local brot = v.Tab.CFrame.p local crot = (arot * .1 + brot * .9) local drot = math.rad((TabletRotation * 1000) * math.pi) v.Tab.CFrame = CFrame.new(crot, pos.p) v.Tab.CFrame = v.Tab.CFrame * CFrame.Angles(drot, drot, drot) v.Tab.CFrame = v.Tab.CFrame * CFrame.Angles(math.pi/2,0,0) end) end end end
1
You have described neither the purpose of this code nor the problem with it. BlueTaslem 18071 — 9y
0
Lol BlueTaslem bobafett3544 198 — 9y

Answer this question