Hello Devs,
I’ve created a script that, when you press a button you become a sort of Part/Model. Whenever the button is clicked, your character goes invisible and is unable to move. The part/model is cloned into the workspace in the position of the player. The camera then switches to the part. (Keep in mind this is supposed to be player specific, which means it’s only supposed to happen to one player)
The script works In studio. But whenever I test the script in-game, the camera no longer switches to the part. But everything else works fine.
I have two scripts, one inside server script service, and the other inside starterGUI.
Here is my current code: (Local script inside startergui)
local Camera = workspace.CurrentCamera local remote = game.ReplicatedStorage:WaitForChild("Remote") local value = game.workspace.Values.Walllnut function onClicked(Player) print("ButtonHasBeenPressed") remote:FireServer("ToasterIsFired") local number = value.Value print(number) local part = workspace:WaitForChild(number) wait(0.1) Camera.CameraType = Enum.CameraType.Custom Camera.CameraSubject = part:WaitForChild("Handle") end game.workspace.StartButton.ClickDetector.MouseClick:connect(onClicked)
(Script inside serverscriptservice)
local object = game.workspace.Wallnut local remote = game.ReplicatedStorage:WaitForChild("Remote") local value = game.workspace.Values.Walllnut remote.OnServerEvent:Connect(function(player, request) if request == "ToasterIsFired" then local number = math.random(1,999999) value.Value = number print(number) print("Request Received") local ClonedObject = object:Clone() ClonedObject.Parent = workspace ClonedObject.Name = (number) ClonedObject.Handle.Position = player.Character.Torso.Position player.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.TeleportPart.Position) end end)
If you need more info about the script, let me know and I can explain in a bit more detail.
If anyone could please help me or point me in the right direction, that would be greatly appreciated! (Sorry if the script is very confusing to read)