Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why will this function not run on chat?

--[[
	Made by, Snow29
--]]

 brick = game.Players.LocalPlayer.Character.Torso  --define
 orbittingbrick = game.Workspace.Tablet --define
 distancefrombrick = 5 --change however you want

function Orbit()
while true do
 for i = 1,360 do
  wait()
   orbittingbrick.CFrame = brick.CFrame * CFrame.Angles(0,math.rad(i),0) * CFrame.new(0,0,-distancefrombrick)
 		end
	end
end

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if(msg == "Orbit") then
           player.Chatted:connect(Orbit)
        end
    end)
end)

Please PM me on roblox or answer here ASAP

3 comments

0

What are you trying to do? What isn't working? Where is the problem? Any output?

0

I want it to orbit a part on the chat "Orbit" , Before game.Players.PlayerAdded:connect(function(player) 19 player.Chatted:connect(function(msg) 20 if(msg == "Orbit") then 21 player.Chatted:connect(Orbit) 22 end 23 end) 24 end) already works

0

I don't understand. What doesn't work and where is it breaking?

2 answers

Your mistake was simple. you put ()'s on line 20 when you dont need them.

--[[
    Made by, Snow29
--]]

 brick = game.Players.LocalPlayer.Character.Torso  --define
 orbittingbrick = game.Workspace.Tablet --define
 distancefrombrick = 5 --change however you want

function Orbit()
while true do
 for i = 1,360 do
  wait()
   orbittingbrick.CFrame = brick.CFrame * CFrame.Angles(0,math.rad(i),0) * CFrame.new(0,0,-distancefrombrick)
        end
    end
end

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if(msg == "Orbit") then
           player.Chatted:connect(Orbit)
        end
    end)
end)

2 comments

0

Thanks!

0

.< Won't work In-Game for some reason,( Also this is a local script) Output:17:00:10.550 - Auto-Saving...

Test the script on something other that local scipt, like just regular script, or screen gui, etc.

This discussion is preserved as it was. New answers, comments, and votes are closed.