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

How can I make a on touched part slowly rotate a part not connected to the script in the workspace?

Asked by 3 years ago
Rotation = workspace.Existing1.Rotation.Vector3.new(0, 157.5, 0)

i = -1

Goal = workspace.Existing1.Rotation.Vector3.new(0, i, 0)

script.Parent.Touched:Connect(function(p)
    if p.Parent:FindFirstChild("Humanoid")then
        p.Parent.Humanoid.WalkSpeed = 0
    end
    do Rotation + Goal until workspace.Existing1.Rotation.Vector3.new(0, 7.5, 0)
    end
end)

Be aware I am really new to Lua.

0
When making a variable make sure to have the word "Local" before naming it. For instance, your first variable should be Local Rotation = workspace.Existing1.Rotation.Vector3.new(0, 157.5, 0) Darth_Revan404 30 — 3y
0
`local Rotation`, not `Local Rotation` Gey4Jesus69 2705 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I can see traces of other programming languages in that script. So first, you need to know what is the procedure of functions. Like, instead of do thing until thing, in lua, it is repeat thing until thing. Second thing, how to set properties. Third, better ways of doing thigs. Rotation isn't using anymore in favor of CFrame, and TweenService would be a better use instead of repeat until. Here is the script, and I'll link api reference for you, as I can't explain everything here.

local tweenService = game:GetService("TweenService")

local part = game.Workspace.Existing1 -- so you don't need to index it over and over again

local tweenInfo = TweenInfo.new(

    1, -- time for the tween to take
    Enum.EasingStyle.Linear, -- easing style, ima link the differences
    Enum.EasingDirection.In -- same for here, though it is the easing direction

)

local tween = tweenService:Create(part,tweenInfo,{CFrame = CFrame.Angles(math.rad(-7.5))}) -- put the angle you want 

part.Touched:Connect(function(hit) -- for touched events you normally would use hit as an argument, though it obviously doesn't make any difference

    if hit.Parent:FindFirstChild("Humanoid") then

        hit.Parent.Humanoid.WalkSpeed = 0

    end

    tween:Play()

end)

TweenInfo TweenService CFrame property CFrame constructor math (scroll down to see math.rad usage) EasingStyle EasingDirection I think that's all. Hope this was helpful.

Ad

Answer this question