I'm trying to get thunder bolts to pop up in random positions when you click. But I'm having some problems.
If I clone the thunder bolt then it won't show up at all. And if I don't then it always goes to the exact same position every time. Here's my code
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, isTyping)
if isTyping then
return
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Clicked")
local SpawnPoints = {UDim2.new({0.029, 0},{0.016, 0}),
UDim2.new({0.844, 0},{0.756, 0}),
UDim2.new({0.91, 0},{0.046, 0}),
UDim2.new({0.757, 0},{0.136, 0}),
UDim2.new({0.56, 0},{0.797, 0}),
UDim2.new({0.56, 0},{0.505, 0}),
UDim2.new({0.705, 0},{0.44, 0}),
UDim2.new({0.599, 0},{0.009, 0}),
UDim2.new({0.398, 0},{0.108, 0}),
UDim2.new({-0.004, 0},{0.312, 0}),
UDim2.new({0.529, 0},{0.222, 0}),
UDim2.new({0.418, 0},{0.637, 0}),
UDim2.new({0.174, 0},{0.748, 0}),
UDim2.new({0.024, 0},{0.65, 0}),
UDim2.new({0.315, 0},{0.34, 0}),
UDim2.new({0.226, 0},{0.555, 0})}
local Bolt = script.Parent.Bolt:Clone()
Bolt.Visible = true
Bolt.Position = SpawnPoints[math.random(1, #SpawnPoints)]
end
end)

1 comment
Why aren't you setting the clone's parent after cloning it?