How would you make it to where when you touch a brick it randomly teleports you to a random region in an enclosed space, as in I put down 4 bricks all around the baseplate, I can then be teleported randomly inside that space but not outside of said space.
Any Help on this subject, and or an Example?
(THIS IS NOT ASKING FOR YOU TO SCRIPT FOR ME, I AM ASKING FOR AN EXAMPLE BECAUSE I HAVE NO CLUE ON HOW TO DO THIS)
LordDragonZord, your answer is really unhelpful. Here's a real, constructive answer.
This can be achieved using math.random. First, we'll identify the length and breadth of the given area (we'll name the area Baseplate as an example). Then, we'll tell math.random to choose any number in between the size of that area. Script:
local area = game.Workspace.Baseplate local x = area.Size.X local z = area.Size.Z local maxX = area.Position.X / (x / 2) local minX = area.Position.X * (x / 2) local maxZ = area.Position.Z / (z / 2) local minZ = area.Position.Z * (z / 2) game.Workspace.Player1.Torso.CFrame = CFrame.new(math.random(minX, maxX), area.Position.Y + 5, math.random(minZ, maxZ)) -- The part in the middle that says "area.Position.Y + 3) means that the player will be teleported 3 studs ABOVE the area, so that they don't get stuck.
If this doesn't work, please tell me and I'll try to fix it!
Use math.random for CFrame so it would look like this:
script.Parent.Touched:connect(function(char) local h = char.Parent.Humanoid if h then h.Parent.Torso.CFrame = CFrame.new(math.random(x,x), 0, math.random(z,z)) -- Change the x and z between two values. I recommend leaving y to 0. So for example, x can be between -4 and 2. end)
script.Parent.Touched:connect(function(char) local h = char.Parent.Humanoid if h then h.Parent.Torso.CFrame = CFrame.new(0,0,0)--Position end)
Locked by BlueTaslem
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?