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

How do I make the work anywhere no matter where the model is Rotated? [Nevermind]

Asked by 8 years ago

I want it to work wherever the whole model is rotated. Like the rotation was like 90, 60, 90 but when I rotated the whole model, it made it like 17, 0, 0. Anyway to fix that problem? This is the same script I asked for the 'or' part, but different situation:

This script is in the position where the X and Z is 90. But if I like rotate the whole model it becomes like 17, 0, 0. So I want it to work no matter where the whole model is rotated. Hope you know what I mean.

This is the link to a video to make it more sense of what is going on! https://www.youtube.com/watch?v=0CiLlWS_Nz4&feature=youtu.be

local tune = game.Workspace.Radio.Tune
local pic = workspace.SongPosters.Decal
sound = Instance.new("Sound", tune)
debounce = false
radioOn = false

function onClicked()
    if debounce then return end --Stop the function if debounce is true.
    debounce = true
    if not radioOn then
        radioOn = true
        tune.Rotation = Vector3.new(tune.Rotation.X, -69.598, tune.Rotation.Z)
        pic.Texture = "rbxassetid://174956680"
        sound.SoundId = "rbxassetid://142295308" --Playing It's Raining Tacos
        sound:Play()
    elseif radioOn and sound.SoundId == "rbxassetid://174654610" then
        radioOn = false
        sound:Stop()
        tune.Rotation = Vector3.new(tune.Rotation.X, -89.282, tune.Rotation.Z)
        pic.Texture = "rbxassetid://271952704"
        print("Off")
    end
    debounce = false
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Log in to vote
0
Answered by 8 years ago

pretty sure the fix is to not use Vector3 and use CFrame because if a moved Vector3 part touches another it will move somewhere to avoid going through it.

example:

local part = script.Parent

function onClick(onClick)
    part.CFrame = part.CFrame * CFrame.fromEulerAnglesXYZ(5, 5, 5)
end

part.ClickDetector.MouseClick:connect(onClick)

i'll try to make it into yours but no promises!

 tune.CFrame = tune.CFrame * CFrame.fromEulerAnglesXYZ(0, -69.598, 0)
0
Thanks, but it's not doing like I wanted it to do. Here is the link of the video of what I wanted it to do: https://www.youtube.com/watch?v=0CiLlWS_Nz4&feature=youtu.be RobotChitti 167 — 8y
Ad

Answer this question