My script is really weird and I don’t understand why I did half of it, so bear with me.
What I am trying to do is create a system where a player goes up to a bank teller and then the teller gets a UI that pops up where they can deposit/withdraw money from the player’s account.
My issue is that UI never opens whenever both players are there and have activated the proximity prompt.
If you have any ideas on how to clean this up as well could you say so.
LocalScript called "Handler" inside the UI
local event = game:GetService("ReplicatedStorage").Banking.DepWith.Communicate
local tellerInterface = script.Parent.TellerInterface
event.OnClientEvent:Connect(function(command, player)
if command == "OpenTellerUi" then
tellerInterface.Enabled = true
end
end)
Server Script that detects the Teller
local prompt = script.Parent.ProximityPrompt
local event = game:GetService("ReplicatedStorage").Banking.DepWith.Communicate
local tellerThere = script.Parent.tellerThere
local tellerVal = script.Teller
prompt.Triggered:Connect(function(teller)
if tellerThere.Value == false then
teller.Character.Humanoid.WalkSpeed = 0
teller.Character.Humanoid.JumpPower = 0
tellerThere.Value = true
tellerVal.Value = teller.Name
prompt.Enabled = false
end
end)
Server Script that detects the Player
local prompt = script.Parent.ProximityPrompt
local event = game:GetService("ReplicatedStorage").Banking.DepWith.Communicate
local tellerThere = script.Parent.Parent.TellerDetection.tellerThere
local tellerVal = script.Parent.Parent.TellerDetection.Script.Teller.Value
if tellerThere.Value == true then
prompt.Triggered:Connect(function(player)
local teller = game.Players:FindFirstChild(tellerVal.Value)
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpPower = 0
event:FireCient(teller, "OpenTellerUi", player)
end)
end
Also, make sure to put your if tellerThere.Value == true then statement in the connection to prompt.Triggered - otherwise, it’ll never connect as at first tellerThere.Value isn’t true.
Fixed code:
local prompt = script.Parent.ProximityPrompt
local event = game:GetService("ReplicatedStorage").Banking.DepWith.Communicate
local tellerThere = script.Parent.Parent.TellerDetection.tellerThere
local tellerVal = script.Parent.Parent.TellerDetection.Script.Teller.Value
prompt.Triggered:Connect(function(player)
if tellerThere.Value == true then
local teller = game.Players:FindFirstChild(tellerVal.Value)
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpPower = 0
event:FireClient(teller, "OpenTellerUi", player)
end
end)
It looks like the value doesn’t exist. Try putting tellerVal inside of the if statement, like this:
local prompt = script.Parent.ProximityPrompt
local event = game:GetService("ReplicatedStorage").Banking.DepWith.Communicate
local tellerThere = script.Parent.Parent.TellerDetection.tellerThere
prompt.Triggered:Connect(function(player)
if tellerThere.Value == true then
local tellerVal = script.Parent.Parent.TellerDetection.Teller.Teller.Value
local teller = game.Players:FindFirstChild(tellerVal.Value)
if teller then
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpPower = 0
event:FireClient(teller, "OpenTellerUi", player)
end
end
end)
local prompt = script.Parent.ProximityPrompt
local event = game:GetService("ReplicatedStorage").Banking.DepWith.Communicate
local tellerThere = script.Parent.Parent.TellerDetection.tellerThere
prompt.Triggered:Connect(function(player)
if tellerThere.Value == true then
local tellerVal = script.Parent.Parent.TellerDetection.Teller.Teller
local teller = game.Players:FindFirstChild(tellerVal.Value)
if teller then
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpPower = 0
event:FireClient(teller, "OpenTellerUi", player)
end
end
end)
Consider making the frames visible to false then change that to visible because the local script can only run if the ui is enabled. Please let me know if I am wrong though.