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

The camera is in the same position for every single position, how can I make it client?

Asked by
Gingerely 245 Moderation Voter
4 years ago
Edited 4 years ago

When a player touches the part, everyone's camera goes to the same position. How can I fix this? It's a local script in starter pack and no errors

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local cam = workspace.CurrentCamera

local debounce = false


workspace.ShopCam.Touched:Connect(function(hit)
if debounce == true then return end

    if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:IsA("Model") then
    debounce = true
    char:FindFirstChild("Humanoid").WalkSpeed = 0 
repeat wait()
    cam.CameraType = Enum.CameraType.Scriptable

until cam.CameraType == Enum.CameraType.Scriptable
cam.CFrame = workspace.CamPart.CFrame
if plr.PlayerGui.ToolShop.Frame.Visible == true then
wait(5)
debounce = false
end
end
end)
plr.PlayerGui:WaitForChild("ToolShop").Frame.Close.MouseButton1Click:Connect(function()
        cam.CameraType = Enum.CameraType.Custom
        char:FindFirstChild("Humanoid").WalkSpeed = 16

end)

1 answer

Log in to vote
1
Answered by 4 years ago

On line 11, we should make sure that:

hit.Parent = plr.Character

Otherwise, any player who touches ShopCam will trigger it.

Ad

Answer this question