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

Change position of items/tools?

Asked by 6 years ago

Hello! Can someone help me? Im creating a map where someone need to find a card and a key. How do i get change the position of the item in every round?

0
This is not a request site but I can still answer you ( Without a code of course ). You can create 4 ( 4 is an example, you can find more ) local positions and use a math.random script. That's all the information I give, find the rest by googling. SwingingMelons -18 — 6y
0
I'd recommend using math.random() and some invisible parts in your workspace. AswormeDorijan111 531 — 6y
0
Sorry for asking, i dont know so much about scripting and im just watching tutorials of everything. Btw thanks a lot! Chronicalr 2 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Chronicalr :

let's say you have the card n' key in workspace:

1local card = workspace.card
2local key = workspace.key

so, we now need to move the MODEL , not the tool object.let's say you put it all in the handle block.

1local random1 = Random.new()
2local place1 = vector3.new(random1.NextNumber(mapxlength/2,mapxlength/2),200,random1.NextNumber(
3-mapxlength/2,mapxlength/2))
4local random2 = Random.new()
5local place2 = vector3.new(random2.NextNumber(mapylength/2,mapylength/2)200,,random2.NextNumber(
6-mapylength/2,mapylength/2))
7card.handle.position = place1
8key.handle.position = place2

put that all in a function to call it any time.(in this case a round) also, if the card is in weird unintended spots, try intending some spots for the card & key to spawn, use random to pick which spot will it spawn at. this is the full script:

01local card = workspace.card
02local key = workspace.key
03function spawn()
04    local random1 = Random.new()
05    local place1 =      vector3.new(random1.NextNumber(mapxlength/2,mapxlength/2),200,random1.NextNumber(
06-mapxlength/2,mapxlength/2))
07    local random2 = Random.new()
08    local place2 = vector3.new(random2.NextNumber(mapylength/2,mapylength/2)200,,random2.NextNumber(
09-mapylength/2,mapylength/2))
10    card.handle.position = place1
11    key.handle.position = place2
12end
13while(1)do
14    wait(100) -- the time of one round
15    spawn()
16end

if you need to use the card or key and deplete it: clone it ,set its parent to workspace every round BEFORE you call the function.

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

how to use random

01Random
02 
03< Global namespace | Roblox namespace
04 
05Random is a datatype used to generate pseudorandom numbers using an dedicated internal state.
06 
07Contents
081   Constructors
091.1 Random.new
102   Methods
112.1 NextNumber
122.2 NextInteger
132.3 Clone
14Constructors
15Random.new
View all 38 lines...

~super

Ad

Answer this question