Basically im making an animation play whenever a proximity prompt is triggered. It works fine in studio but breaks in game.
In studio:
In game:
Localscript:
local prox = game.Workspace.Spawn.AppleShakeTree.Attachment.ProximityPrompt
local proxProm = game.Workspace.Spawn.Apples.Apple2.ProximityPrompt
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local controls = PlayerModule:GetControls()
local hum = char:WaitForChild("Humanoid")
local humanoid = player.Character:WaitForChild("HumanoidRootPart")
local hum2 = game.Workspace.NPCS.SuspiciousPerson.Humanoid
local playerA = script.Apples1
local NPCB = script.Apples2
local playerTrackAB = hum:LoadAnimation(playerA)
local NPCTrackBB = hum2:LoadAnimation(NPCB)
local cam = workspace.CurrentCamera
local ContentProvider = game:GetService("ContentProvider")
local Suspicious = hum2.Parent
game.Players.PlayerAdded:Connect(function()
ContentProvider:PreloadAsync(script.Apples1, script.Apples2)
end)
prox.Triggered:Connect(function()
if game.Players.LocalPlayer:WaitForChild("Appealed").Value == 0 and game.Players.LocalPlayer:WaitForChild("ApplesGiven").Value == 0 then
Suspicious.Head.Transparency = 0
Suspicious["Right Arm"].Transparency = 0
Suspicious["Left Arm"].Transparency = 0
Suspicious["Right Leg"].Transparency = 0
Suspicious["Left Leg"].Transparency = 0
Suspicious.Torso.Transparency = 0
humanoid.CFrame = game.Workspace.CFrames.Apples.CFrame
game.Workspace.Spawn.Apple.Transparency = 1
game.Workspace.Spawn.Apples:WaitForChild("Apple2").Transparency = 0
proxProm.Enabled = true
game.Players.LocalPlayer.CameraMaxZoomDistance = 0
game.Players.LocalPlayer.CameraMinZoomDistance = 0
cam.CameraType = Enum.CameraType.Attach
cam.CameraSubject = game.Workspace.NPCS.CameraPoints.ApplePartCFrame
controls:Disable()
task.wait(.5)
game.Players.LocalPlayer.PlayerGui.LoreGui.Lore1Text.TextTransparency = 0
game.Players.LocalPlayer.PlayerGui.LoreGui.Lore1Text.Text = "Hey."
playerTrackAB:Play()
NPCTrackBB:Play()
wait(0.28)
game.Players.LocalPlayer.PlayerGui.LoreGui.Lore1Text.Text = "Why you collecting apples Whats the occasion?"
wait(1.07)
game.Players.LocalPlayer.PlayerGui.LoreGui.Lore1Text.Text = "Just don't mind it"
wait(0.63)
game.Players.LocalPlayer.PlayerGui.LoreGui.Lore1Text.Text = "Alright then."
wait(1)
game.Players.LocalPlayer.PlayerGui.LoreGui.Lore1Text.TextTransparency = 1
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = hum
game.Players.LocalPlayer.CameraMaxZoomDistance = 150
game.Players.LocalPlayer.CameraMinZoomDistance = 0
controls:Enable()
Suspicious.Torso.Transparency = 1
Suspicious["Left Arm"].Transparency = 1
Suspicious["Left Leg"].Transparency = 1
Suspicious["Right Arm"].Transparency = 1
Suspicious["Right Leg"].Transparency = 1
Suspicious.Head.Transparency = 1
end
end)