Im trying to create a shop system, but ive run into a small problem and im not sure what the cause of it is.
For some reason teh camera just clicks back into its original position. Im not sure why this is happening or whats causing the problem. Some help would be really apprciated!
heres my code
repeat task.wait(1) until game:IsLoaded()
local shopPart = workspace:WaitForChild("Shop").ShopActivator
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local HRP = char:WaitForChild("HumanoidRootPart")
local IsEnabled = false
local RS = game:GetService("RunService")
local BP = player.Backpack
local camera = workspace.CurrentCamera
local TS = game:GetService("TweenService")
local originalCamPos
local shopCam = workspace.Cameras:WaitForChild("ShopCam").RP
local dGUI = player.PlayerGui["Dialogue UI"]
local shopGUI = player.PlayerGui["Shop UI"]
--[[
RS.Stepped:Connect(function(FPS)
if (shopPart.Position - HRP.Position).Magnitude < 10 then
IsEnabled = true
print(player.Name, "is near the shop")
if IsEnabled == true then
--Camera Editing
camera.CameraType = Enum.CameraType.Scriptable
TS:Create(camera, TweenInfo.new(.3), {CFrame = shopCam.CFrame}):Play()
dGUI.Enabled = true
for i, descendant in pairs(dGUI:GetDescendants()) do
if descendant:IsA("Script") or descendant:IsA("LocalScript") then
descendant.Disabled = false
end
end
else
camera.CameraType = Enum.CameraType.Custom
end
else
IsEnabled = false
print(player.Name, "is not near the shop")
dGUI.Enabled = false
shopGUI.Enabled = false
end
end)]]
local Promt = shopPart.Prompt
Promt.Triggered:Connect(function(plr)
print(plr.Name, "triggered shop")
IsEnabled = true
if IsEnabled == true then
--Camera Editing
camera.CameraType = Enum.CameraType.Scriptable
TS:Create(camera, TweenInfo.new(.3), {CFrame = shopCam.CFrame}):Play()
dGUI.Enabled = true
for i, descendant in pairs(dGUI:GetDescendants()) do
if descendant:IsA("Script") or descendant:IsA("LocalScript") then
descendant.Disabled = false
end
end
end
end)
Promt.TriggerEnded:Connect(function(plr)
print("trigger ended")
end)
thank you for your time
