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

I need help making two things work at once + I also need help with something that goes after that?

Asked by 5 years ago

I currently have a script that when a player touches a brick it'll go up by 5 studs, spin by a degree of 5 every 0.01 second for 100 rotations of the 5 degrees, that part is working, but I need help with making the moving and spinning at the same time. I also need help on how to make it slowly add 0.1 to it's transparency. It gives 5 points then destroys the brick. The script is:

    --// Variables \\--
local part = script.Parent
local newPos = part.Position + Vector3.new(0,5,0)
local Time = 1
local Inc = 0.1
local db = false
local Diff = newPos - part.Position
local Mag = Diff.magnitude
local Direction = CFrame.new(part.Position, newPos).LookVector
local a = 100
local b = 10
--// Main Script \\--
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if db == false then
db = true
for n = 0, Mag, Inc do
part.CFrame = part.CFrame + (Direction * Inc)
wait( (Time/Mag) * Inc )
end
while true do
part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(5), 0)
wait(0.01)
a = a - 1
if a == 0 then
break
end
end
while true do
part.Transparency = 0.1
wait(0.01)
b = b - 1
if b == 0 then
break
end
end
player.leaderstats.Points.Value = player.leaderstats.Points.Value + 5
script.Parent:Destroy()
db = false
end
end
end)

I currently have it all formatted correctly, but it transfers over into the script brackets weirdly with the new system. Also help please? Thanks a ton!

Answer this question