Hello. i wrote some script for my game yesterday and the game was working fine. during school i decided i should add TweenService to animate the brick when a player clicks it
notes: script is local, parts used to spawn but dont anymore.
this is confusing me a lot becuase it should work and i dont see why it doesnt, it just doesnt want to.
heres the script:
while wait() do
wait(1)
script.Parent.Text = 'loading... 1 '
wait(1)
script.Parent.Text = 'loading... 2 '
wait(1)
script.Parent.Text = 'loading... 3 '
script.Parent.Text = 'error loading '
local Part = Instance.new("Part")
Part.Parent = game.Workspace
Part.BrickColor = BrickColor.Random()
Part.Material = 'Metal'
local A = math.random(-500,500)
local B = 0
local C = math.random(-500,500)
Part.Position = Vector3.new(A, B, C)
local pos = Part.Position
script.Parent.Text = tostring(Part.Position)
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = Part
clickDetector.MouseClick:Connect(function(player)
script.Parent.Text = (player.Name.. " clicked the brick")
game:GetService("ReplicatedStorage"):FindFirstChild("updateCash"):FireServer()
local tweenService = game:GetService("TweenService")
local part = Part
local tweeningInformation = TweenInfo.new(1, Enum.EasingStyle.Back, Enum.EasingDirection.In, 1, false,)
local partProperties = {
Size = Vector3.new(0.1,0.1,0.1),
Color = Color3.new(0, 0, 0),
Transparency = 0.5
}
local Tween = TweenInfo:Create(part, tweeningInformation, partProperties)
Tween:Play()
Part:Remove()
end)
end
Thanks if your able to help.
this might help as well:
important edit: The bricks are appearing in workspace however they get deleted shortly afterwards