#How do i set the players current camara

1 messages · Page 1 of 1 (latest)

wicked flower
#

So i want to set the players current camera when a proximity prompt is interacted with, i currently have these two codes, the second one is in starter player scripts

local prompt = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeCameraEvent = ReplicatedStorage:WaitForChild("RemoteEvents").ChangePlayersCamera

prompt.Triggered:Connect(function(player)
    local targetCamera = script.Parent.Parent.Parent.Parent.EggView
    if targetCamera and targetCamera:IsA("Camera") then
        ChangeCameraEvent:FireClient(player, targetCamera)
    else
        warn("TargetCamera not found or is not a Camera!")
    end
end)```

```lua
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local ChangeCameraEvent = ReplicatedStorage:WaitForChild("RemoteEvents").ChangePlayersCamera

ChangeCameraEvent.OnClientEvent:Connect(function(targetCamera)
    print("Camera Change Event Runned")
    if targetCamera and targetCamera:IsA("Camera") then
        camera.CameraType = Enum.CameraType.Scriptable

        local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
        local tween = TweenService:Create(camera, tweenInfo, {
            CFrame = targetCamera.CFrame
        })
        tween:Play()
    else
        warn("Invalid camera received! ", targetCamera)
    end
end)
#

currently i get the error
17:25:16.984 Invalid camera received! nil - Client - LocalScript:20

cold pendant
#

cameras are not replicated

wicked flower
#

The camara is inside another part

cold pendant
wicked flower
#

I want to set the players camara when interacted with a prompt

cold pendant
#

so do that on the client

wicked flower
#

Yes that’s why I used the local script inside player scripts

#

And a remote event

cold pendant
#

cameras do not replicate

#

and i'm pretty sure you can't cache them either

wicked flower
#

How do I do it then?

cold pendant
#

meaning if you create them in edit mode, they get destroyed when you press play

wicked flower
#

Ohh right

#

Sorry

cold pendant
#

doesnt matter where they are

wicked flower
#

Sorry if I create the camara before I send the remote event

#

Does it work then?

cold pendant
#

anything involving a Camera instance must stay on one side of the client/server boundary

#

i.e you can't create cameras on the server to send to the client

#

you have to do it on the client instead

wicked flower
#

Right

#

So what if I pass though a part of where to put the canara

#

And like the important info like size height e.g

#

That work?

cold pendant
wicked flower
#

Ohh right makes much more sense

#

I’ll try it and let you know thanks

cold pendant
#

you lose a bit of control since the camera has more properties like fov, but you can easily contend with that with some numbervalues or whathaveyou to pass around the properties you want to use

wicked flower
#

So by setting attributes?

cold pendant
#

attributes could work too, idk however you want to pipe the values around

wicked flower
#

one thing @cold pendant

#

so this is my code, when i set it back it doesnt go to like the third person view it goes to the middle of my body the animation

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local ChangeCameraEvent = ReplicatedStorage:WaitForChild("RemoteEvents").ChangePlayersCamera

ChangeCameraEvent.OnClientEvent:Connect(function(targetPart)
    if camera.CameraType == Enum.CameraType.Custom then
        camera.CameraType = Enum.CameraType.Scriptable

        local targetCFrame = targetPart.CFrame

        local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
        local tween = TweenService:Create(camera, tweenInfo, {CFrame = targetCFrame})
        tween:Play()

        tween.Completed:Connect(function()
            print("Camera reached target part.")
        end)

        return true
    elseif camera.CameraType == Enum.CameraType.Scriptable then
        local playerCharacter = game.Players.LocalPlayer.Character
        local playerCFrame = playerCharacter.HumanoidRootPart.CFrame

        local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
        local tween = TweenService:Create(camera, tweenInfo, {CFrame = playerCFrame})
        tween:Play()

        tween.Completed:Connect(function()
            camera.CameraType = Enum.CameraType.Custom
            print("Camera moved back to player.")
        end)

        return true
    else
        warn("Unexpected Camera Type:", camera.CameraType)
    end
end)

cold pendant
wicked flower
#

because i dont have the CFrame for it right?

cold pendant
wicked flower
cold pendant
wicked flower
#

actually is there a way to make the player not see other players

#

and themself

cold pendant
#

including this one.

wicked flower
#

but its just long?

cold pendant
#

you just, might not like the techniques to do it.

wicked flower
#

yeah im good then

#

im not going into that then

cold pendant
#

i would think sinking inputs is easier, idk i haven't delved into a custom camera yet

#

but i want to

#

pretty sure its in the roblox PlayerModule

wicked flower
#

okay @cold pendant this question is a bit random but do you have any idea / video / docs or anything on how to make some sort of finish hatching animation, so im talking some kind of mini explotion but not? cloud effect kinda thing

#

not sure how to do this

#

its for a part as well

#

not a gui

cold pendant
#

i'm sure you can find a tutorial on youtube for that

#

not that i support that garbaje

#

imo roblox got enough pet sim slop

wicked flower
wicked flower
#

more just bored

#

most games i make i spend hours and dont complete

cold pendant
#

it gets a lot easier when you're in an active dev cycle

#

i.e game finished and people playing it and giving feedback. much easier then. so it does end eventually

wicked flower
#

yeah i bet it does

#

making the game and getting it all together and working is so annyoing

cold pendant
#

easier to polish small features at a time than a whole game at once

wicked flower
#

like one little thing i want to add to make the game look nicer takes hours

wicked flower
wicked flower
#

i bet it is

#

pain though

cold pendant
#

who'da suspected, game dev is time consuming

#

and difficult

wicked flower
#

yep very

#

@cold pendant can i ask another unrelated question

#

or do u want me to open another form

cold pendant