-
What am I making? I’m making a placement system, the script is placed in startergui and it’s a localscript.
-
What do I want to achieve? If the player holds R or Q on their keyboard, the model keeps rotating and if the player stops, then the model stops rotating
-
What is the issue? The model won’t rotate, no errors in output too
-
What solutions have you tried so far? No solutions so far
local Player = game:GetService("Players").LocalPlayer
local UIS = game:GetService("UserInputService")
local Storage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Folder = Storage:FindFirstChild("Furniture")
local Model = Folder:FindFirstChild("Table")
local Mouse = Player:GetMouse()
local UI = script.Parent
local NewModel = Model:Clone()
NewModel.PrimaryPart = NewModel.Hitbox
local Loop = false
local Loopq = false
for i,v in pairs(UI.ScreenGui:GetChildren()) do
if v:IsA("TextButton") then
UI.ScreenGui.TextButton.MouseButton1Click:Connect(function()
NewModel.Parent = game.Workspace
RunService.RenderStepped:Connect(function()
Mouse.TargetFilter = NewModel
local NewCFrame = CFrame.new(Mouse.Hit.X, Mouse.Hit.Y, Mouse.Hit.Z)
NewModel:SetPrimaryPartCFrame(NewCFrame)
end)
UIS.InputBegan:Connect(function(Input)
if UIS:IsKeyDown(Enum.KeyCode.Q) then
Loopq = true
while Loopq do
wait()
local y = NewModel.PrimaryPart.Orientation.Y
y = y - 3
NewModel:SetPrimaryPartCFrame(CFrame.Angles(0, math.rad(y), 0))
end
end
end)
UIS.InputEnded:Connect(function(Input)
if UIS:IsKeyDown(Enum.KeyCode.Q) then
Loopq = false
end
end)
UIS.InputBegan:Connect(function(Input)
if UIS:IsKeyDown(Enum.KeyCode.R) then
Loop = true
while Loop do
wait()
local y = NewModel.PrimaryPart.Orientation.Y
y = y + 3
NewModel:SetPrimaryPartCFrame(CFrame.Angles(0, math.rad(y), 0))
end
end
end)
UIS.InputEnded:Connect(function(Input)
if UIS:IsKeyDown(Enum.KeyCode.R) then
Loop = false
end
end)
end)
end
end