Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Rotating model when pressing R key not working?

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)
		

4 comments

0

What is the other code? All you have to do is Copy paste. Does it give you any errors? Your tabbing is like... excessive

0

The other code is for an highly advanced model-placement system.. 400 lines long.. just..no. And btw it does not give me any errors.

0

Are you getting the player input from a Server script, or are you trying to move the block with a Local Script? If so, your script is either unable to access player input or rotate the block on the server level, respectively. Such is due to the script not being the appropriate type.

0

Server scripts cannot access player input, nor can Local Scripts change an object's position and replicate it to the server; local scripts can only change an object's position for your client. The new position would not be reflected on the server, and thus, to other players.

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.