Why isn't this rotating my model?
There are no errors.
Please note: I have set the 'uis' and other shortened stuff to the corresponding things earlier in the script.
Here is the part of the very long local script that fires a remote functions when the R key is pressed:
uis.InputBegan:connect(function(inst) if Rotating == false then if placing == true then if inst.KeyCode == Enum.KeyCode.R then local RotateEvent = game.Workspace.RemoteFunctions:FindFirstChild("RotateEventFor"..player.Name) RotateEvent:InvokeServer(id) Rotating = true end Rotating = false end end end)
Here is the part of the very long server side script that should start whenever the remote function is fired:
function event3.OnServerInvoke(id) local PartToRotate = game.Workspace:FindFirstChild("id",true).Value == id for i,v in pairs(game.Workspace:GetChildren()) do if v.Name == "ModelToPlaceFor"..plr.Name then if v:FindFirstChild("id").Value == id then PartToRotate = v.Parent PartToRotate:SetPrimaryPartCFrame(CFrame.new(PartToRotate.PrimaryPart.CFrame)*CFrame.Angles(0,0,math.rad(90 + PartToRotate.PrimaryPart.CFrame.Z))) end end end end
As I previously stated;
There are 0 errors when I press the 'R' key in game, and I know that it connects correctly because I debugged it when the output said various stuff that I needed to fix.
Any help is greatly appreciated!
The first parameter on OnServerEvent and OnServerInvoke are always the local player's object. (so do not make a remoteevent for each player)
so instead of
function event3.OnServerInvoke(id)
do
function event3.OnServerInvoke(player, id)