✓ Accepted answer
The problem is that your LocalScript is local, and since your part is created on the server, IE: In studio, the LocalScript simply wont work. This is problematic since the camera can only be changed locally, and we already know that we can't use a LocalScript to detect when the part collides with something.
The easiest way to bypass this would be by using a RemoteEvent to send a message through the client-server boundary. In this example we'll be creating a RemoteEvent object and placing it inside the ReplicatedStorage, this storage basically replicates objects inside so that they exist in both server-space and local-space, which is perfect for what we want. For convenience, we'll name the RemoteEvent object 'touchBrick'.
Since we want to send a message to the client we will use the FireClient() function, which uses a Player object as its first argument, this decides who the message will be sent to.
Then we can use the OnClientEvent function to detect when the LocalScript receives a message.
Server Script
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.touchBrick:FireClient(player)
end
end)
Local Script
game.ReplicatedStorage.touchBrick.OnClientEvent:Connect(function())
workspace.CurrentCamera.CFrame = workspace.CAMS.S1B.CFrame
end)
5 comments
You need to set the camera type to Scriptable
-- to edit camera Camera.CameraType = Enum.CameraType.Scriptable -- default camera Camera.CameraType = Enum.CameraType.Custom@BoomerNEW_GEN please use the developer hub/devforum for reference in the future, otherwise your question may be closed as "Not Constructive!" if you'd like to learn how to post a good question, then here' the link: https://scriptinghelpers.org/help/how-post-good-questions-answers:
The problem is that it already is on Scriptable. Sorry for not clarifying.
i dont see a problem with this question though? @JesseSong
^