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

Rotating model when pressing R key not working?

Asked by
nanaluk01 247 Moderation Voter
7 years ago

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)

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 LisaF854 93 — 7y
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. nanaluk01 247 — 7y
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. tkcmdr 341 — 7y
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. tkcmdr 341 — 7y

1 answer

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
7 years ago

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.

Ad

Answer this question