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

Rotating a model by keypress?

Asked by
k1nq 30
8 years ago
game["Run Service"].RenderStepped:connect(function()
    if Mouse.target then
        CloneFrom.Model:SetPrimaryPartCFrame(CFrame.new(math.floor(Mouse.hit.p.X),math.floor(game.Lighting[script.Parent.Parent.PlayerGui.Gui.Insert.Value].Model.Primary.Position.Y),math.floor(Mouse.hit.p.Z)))
    end
end)

Mouse.KeyDown:connect(function(key)
    if key == "r" then
        local model = CloneFrom.Model
        model.PrimaryPart = model.Primary
        model:SetPrimaryPartCFrame()
    end
end)

Above is my current code.

I've tried different ways for the SetPrimaryPartCFrame() rotation but I can't seem to make it work

Any help?

1 answer

Log in to vote
0
Answered by 8 years ago

UIS

KeyDown is deprecated, use the UserInputService instead.

Example:

local uis = game:GetService("UserInputService")

uis.InputBegan(function(InputObject)
    if inputObject = Enum.KeyCode.R then
    --Code Here
    end
end)

http://wiki.roblox.com/index.php?title=API:Class/UserInputService

I'm not sure what you can do next, try looking inside the ROBLOX tools to see how they did it.

Ad

Answer this question