Proximity wont trigger in game, but GUI does

Hello! I am trying to trigger my proximity prompt using a local script for a tween. Before it used GUI but now uses the proximity prompt. The problem is that when I moved that code and changed the function. It didn’t do anything. The proximity prompt showed up but will not trigger. Am I doing something wrong?

GUI (Works):

--Made by w_blu
local TweenService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local CurrentCamera = workspace.CurrentCamera
local Time = 0.5 --Time in seconds for the tween
local Repeat = 0 --How many times the tween repeats


script.Parent.MouseButton1Click:connect(function()
	CurrentCamera.CameraType = Enum.CameraType.Scriptable
	local Tween = TweenInfo.new(Time, Enum.EasingStyle.Quad, Enum.EasingDirection.In, Repeat)
	local Goal = {CFrame = workspace.End.CFrame}
	local Anim = TweenService:Create(CurrentCamera, Tween, Goal)
	Anim:Play()
	wait(Time)

end)

Proximity Prompt (Doesn’t work)

--Made by w_blu
local TweenService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local CurrentCamera = workspace.CurrentCamera
local Time = 0.5 --Time in seconds for the tween
local Repeat = 0 --How many times the tween repeats
local ProximityPrompt = script.Parent

ProximityPrompt.Triggered:connect(function(player)
	print("Triggered!")
	CurrentCamera.CameraType = Enum.CameraType.Scriptable
	local Tween = TweenInfo.new(Time, Enum.EasingStyle.Quad, Enum.EasingDirection.In, Repeat)
	local Goal = {CFrame = workspace.End.CFrame}
	local Anim = TweenService:Create(CurrentCamera, Tween, Goal)
	Anim:Play()
	wait(Time)

end)

LocalScripts don’t work as descendants of the workspace. You should move this script to somewhere that runs LocalScripts (such as StarterPack, StarterGui, or StarterPlayerScripts).

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.