I want to make some, but how do I weld the brick to me and "animate" the brick without moving my character? Here's what I have so far;
wait(3) p = Instance.new("Part", game.Workspace) c = Instance.new("ClickDetector", p) local f = game.Workspace.FrstZ p.TopSurface = "Smooth" p.BottomSurface = "Smooth" p.CanCollide = false p.Size = Vector3.new(0, 1, 0, 1) p.Material = "Neon" p.BrickColor = BrickColor.new(1019) local w1 = Instance.new("Weld", p) w1.Part0 = f.Torso w1.Part1 = p w1.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0, 5) wait(.25) w1.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(2, 0, 5) wait(.25) w1.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(0, 0, 5) -- This is good for animating, I guess, but I don't know how to loop it and do it without moving my char. function yoyoyo(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.Q then p.BrickColor = BrickColor.Random() end end game:GetService("UserInputService").InputBegan:connect(yoyoyo) local function onMouseClick(player) end c.MouseClick:connect(onMouseClick)
Welds typically aren't used for admin tablets. We generally CFrame the tablet to a location relative to the player. The script you provided uses welds, so I'll have to write some new code for you, and if you decide to use it, you'll have to scrap your weld script.
First, create a table that will contain the references to the tablets, and some variables for the rotation of the tablets around the player.
Tablets = {} -- The tablet table. rot = .1 -- A point on a circle around the player. rot2 = 0.001 -- The speed at which the tablets will orbit the player.
Then, create a function that will create the tablet and add it to the table.
function Output(Player,Color) --This takes 2 args. The player and tab color if Color==nil then Color='New Yeller' end -- If color isn't supplied, set it to yellow. local main = Instance.new("Part") -- Create the tab. main.FormFactor='Custom' main.CanCollide = false -- Tabs can clip through things. main.Anchored = true -- Gravity and physics don't apply to it. main.Name = 'Tab' -- Just naming it. main.Parent = workspace -- Parent it to workspace. main.BrickColor = BrickColor.new(Color) -- Set its color. main.Size = Vector3.new(2,2,2) -- Set its size. pcall(function() main.CFrame = Player.Character.Torso.CFrame end) -- CFrame it to the player. table.insert(Tablets,{Tab=main,Player=Player}) -- Add it to the tabs table end
Now, create a function that will update the tablet's position. Uses fairly complicated math.
function UpdateTablets()pcall(function() -- Takes no args, pcalled in case the player or its character is nil. rot=rot+rot2 -- Rotate the position around the palyer for _,Player in pairs(game:service'Players':GetPlayers()) do -- For each player local PlayerTablets = {} -- Create a table for the tablets belonging to the player for i,v in pairs(Tablets) do -- For each tablet if v.Tab.Parent ~= nil and v.Player==Player then -- If the tab belongs to the player table.insert(PlayerTablets,v) -- Add the tablet to the list of tablets for that player end end local Start = CFrame.new(0,0,0) -- Create a CFrame for the tab for I = 1, #PlayerTablets do -- For each tab belonging to the player radius = (#PlayerTablets*.6)+4 -- Set the radius of the circle around the player Pos = Player.Character.Torso.CFrame -- Make a variable for the player's position local Main = (I / #PlayerTablets - (0.3 / #PlayerTablets) + rot/(#PlayerTablets/7)) * math.pi * 2 -- Distance from player depending on the number of tablets around them so they don't clip into each other local x = math.sin(Main) * radius -- Set the position on the X axis to the distance from the player local y = math.sin(math.sin(tick())+360/#PlayerTablets+rot+rot2+I/tick(),0) -- Set the position on the Y axis. This code also makes the tabs bob up and down. local z = math.cos(Main) * radius -- Set the position on the Z axis to the distance from the player local aPos = Vector3.new(x, y, z) + Pos.p -- Add everything we just did to the player's position local bPos = PlayerTablets[I].Tab.CFrame.p -- Create a variable with the Tablet's current position. local cPos = aPos * .1 + bPos * .9 -- Create a variable with the new position of the tab. PlayerTablets[I].Tab.CFrame = CFrame.new(cPos, Pos.p)-- Finally, set the new CFrame of the tab. end end end) end
Yes, that was complicated, but it's necessary. Now we need to call that function. Repeatedly. Really, really quickly. To do that, we can utilize the game's RunService.Stepped.
game:service'RunService'.Stepped:connect(UpdateTablets) -- On every step, update the position of the tabs using the function we just made.
Now, to create a tab, we just do something like this:
Output(game.Players.YourUsernameHere,"New Yeller") -- Create the tab for your player with the color "New Yeller".
Good luck with your admin tabs.