Rotating model when pressing R key not working.
I am trying to rotate a model when I press the R
-key, but it does not seem to work. Why?
What am I doing wrong?
I have made sure that cloneModel
does exist, I have made sure of that earlier in my script. Therefore, I have not included it here because it is too much code to put into here.
Any help with this is greatly appreciated!
r = 0 rotating = false uis.InputBegan:connect(function(inst) if Rotating == false then if inst.KeyCode == Enum.KeyCode.R then rotating = true r = r + 90 cloneModel:SetPrimaryPartCFrame(CFrame.new(cloneModel.PrimaryPart.Position) * CFrame.Angles(0,0,math.rad(r))) if r == 360 then r = 0 end end Rotating = false end end)
As others have said, script type. I will explain it in more detail though. Server and local scripts are made for different purposes, and each have their limits. Server scripts are more for game logic, handling a leaderboard, for example. Local scripts are for handling things on the client, like gathering user input, or hiding the top bar. Neither can do the other. Server scripts can't get user input, and local scripts can't modify leaderboards on other clients, but just the users client. The thing you can do though, is use remove events/functions to communicate between these scripts.