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

How to clone a tool and place random pos in the workspace?

Asked by
c0nc3rt 61
5 years ago

Well, my problem is really anoying, just take a look at my script first:

local val = game.ReplicatedStorage.Value
local sword = game.ServerStorage.ClassicSword

while true do
sword:Clone() --clone the sword

sword.Parent = workspace --set parent
local swordinwsp = workspace:WaitForChild("ClassicSword")

swordinwsp.Handle.Position = Vector3.new(math.random(-95,171), 30, math.random(-84,181)) --random the position of the cloned sword


val.Value = val.Value + 1 --don't care about this line
wait(5) --delay

end

That script will make the sword clone and parent it in the workspace but it only clone one and make it teleport it everywhere

Well, after searching internet for a while i made a new one, but worse

local val = game.ReplicatedStorage.Value
local sword = game.ServerStorage.ClassicSword

while true do
sword:Clone().Parent = workspace --just quickly clone at set the parent

local swordinwsp = workspace:WaitForChild("ClassicSword")

swordinwsp.Handle.Position = Vector3.new(math.random(-95,171), 30, math.random(-84,181))


val.Value = val.Value + 1 --don't care about this line
wait(5)

end

And it just clone a sword and move it randomly and more cloned sword is coming from the middle of the workspace (not move to a random location)

I think there must be a way to fix it but I haven't figured out.

Really appreciate with your answer!

1 answer

Log in to vote
0
Answered by
0msh 333 Moderation Voter
5 years ago

I don't know if you're looking for something like this, but yeah.

local ser = game:GetService("ReplicatedStorage")
local w = ser:WaitForChild("Tool")
local tool = ser:FindFirstChild("Tool")

while true do
    local clone = tool:Clone()
    clone.Parent = workspace
    local x = math.random(-100,100)
    local z = math.random(-100,100)
    clone.Handle.CFrame = CFrame.new(Vector3.new(x,40,z))
    wait(5)
end
0
sorry not work bro, but thanks for your help. c0nc3rt 61 — 5y
0
how does it not work? you'll have to modify some lines yourself, such as line 1 and 3 because I'm targeting the Replicated Storage and you're targeting the Server Storage 0msh 333 — 5y
0
I modfied it, but still not work lol. It didn't clone anythinng from the server sotrage c0nc3rt 61 — 5y
0
from the server storage then you'll have to use remotes, just make that a local script and fire a remote in replicated storage then finish it off with a script in server script service 0msh 333 — 5y
Ad

Answer this question