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

How exactly would i trigger CameraManipulation when a player touches a part?

Asked by 4 years ago
Edited 4 years ago

Hello, I have recently tried CameraManipulation and want to trigger it with a part in workspace. I want it so it triggers when a player touches the TriggerPart and stops when the player moves away from the TriggerPart. I am having difficulty with scripting this and need some help.

To give you a basic idea: -There is a part in workspace called CamPart (The one that is used for the camera, Not as a trigger.) -Part in workspace called TriggerPart. (Used for triggering the script when a player touches.) -ScreenGUI in StarterGUI with a LocalScript.

The script in StarterGUI is as follows:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

repeat wait()
    Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.CamPart.CFrame

Thank you for your time!

0
.Touched, look it up. Ziffixture 6913 — 4y

2 answers

Log in to vote
0
Answered by
VAHMPIN 277 Moderation Voter
4 years ago
Edited 4 years ago

here. - PUT IN A PART (INVISIBLE + NOCOLLIDE)

local debounce = false

function TouchEvent(Trigger)
  if debounce == false and Trigger.Parent:FindFirstChild("Humanoid") then
local Player = game.Players[Trigger.Parent.Name]
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
debounce = true

repeat wait()
    Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.CamPart.CFrame
 end
end

script.Parent.Touched:Connect(TouchEvent)
0
forgot debounce values, edited in. VAHMPIN 277 — 4y
0
Still won't trigger for some reason.. Is there something i'm missing? Daniel2930142 0 — 4y
0
give me the problem / error VAHMPIN 277 — 4y
0
The script which i stated was in startergui, there are also 2 parts in workspace. CamPart, The one associated with the script, And TriggerPart, The one the player steps on to trigger the script in startergui. Daniel2930142 0 — 4y
View all comments (7 more)
0
ah, i realise my error hold on. VAHMPIN 277 — 4y
0
i edited it, try the script on 1 part now. (I can't test it right now, sorry) - this script should also work for all players now VAHMPIN 277 — 4y
0
So i insert the script inside TriggerPart? Daniel2930142 0 — 4y
0
yes - if you want it local make it game.Players.LocalPlayer in a localscript. VAHMPIN 277 — 4y
0
I still have trouble getting it to work. Mind if i link you a free model of it that i uploaded? Daniel2930142 0 — 4y
0
i can't access the roblox website and i can't access roblox studio currently, therefore i'm only trying to help to my best extent. Sorry. - if there's still problems later when i can i'll surely test it out. VAHMPIN 277 — 4y
0
Oh, Alright. Daniel2930142 0 — 4y
Ad
Log in to vote
0
Answered by
Kizonn 0
4 years ago

Camera manipulation is local so you would have to either use a RemoteEvent that triggers the client when touching the part, or have a LocalScript that detects when your player touches anything, checks if it's the right part, then it manipulates the camera.

Answer this question