✓ Accepted answer
Errors in your code:
I. You tried to use the Touched/TouchEnded events on the client, use a RemoteEvent and fire the Camera change to the client, while handling the touch event from the server.
II. You are using deprecated code.RBXScriptSignal:connect() is deprecated, switch to RBXScriptSignal:Connect()
III. In line 4, CameraType holds an Enum value, although technically it’s okay to assign an Enum value with a string, if you are checking if an Enum property value equals a specific enum, you must specify the Enum in conditional statements. These are conditional statements, and if a property holds an Enum value, the Enum value must be specified.
Take these for example:
if Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
end
while PlayerGui.ScreenGui.Frame.Style == Enum.FrameStyle.ChatGreen do
end
repeat
until game.Workspace.Part.Shape == Enum.PartType.Ball
IV. The event is BasePart.TouchEnded, not TouchedEnded.
script.Parent.TouchEnded:Connect(function(part)
local plr = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
if plr then
game.Workspace.ChangeCamType:FireClient(plr)
end
end)
Code for the remote event.
game.Workspace.ChangeCamType.OnClientEvent:Connect(function()
local camera = game.Workspace.CurrentCamera
if camera.CameraType == Enum.CameraType.Scriptable then
camera.CameraType = Enum.CameraType.Custom
end
end)
5 comments
No it isn't mandatory. I could do repeat wait() workspace.Part.Shape = "Ball"; until workspace.Part.Shape == "Ball"; and it would still work.
no...
You need to use an enum in conditional statements. http://wiki.roblox.com/index.php/#Using_Enumerations
What would 'ChangeCamType' be?
A RemoteEvent inside of Workspace.