You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Properly delete the prompt for the client after the character respawns -
What is the issue? Include screenshots / videos if possible!
Im having issues with the code im running when the character respawns its supposed to handle the clients proximityPrompt deleting it locally to hide it. Now upon joining there’s no issues its when the character respawns is when the prompt becomes visible for them is the issue This is my server script.
[2 Player [Rework] - Roblox Studio (gyazo.com)]
(https://gyazo.com/db5ccebd37808a3d1b1a1bc1b3b6988c)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
print("Spawned Setting up " ,char)
local remote = game.ReplicatedStorage.RemotesFolder.Event
local Prompt = Instance.new("ProximityPrompt")
Prompt.Parent = char
Prompt.Name = "PairRequestPrompt"
Prompt.ObjectText = "Send Pair request"
Prompt.HoldDuration = 2
Prompt.MaxActivationDistance = 3
char.Humanoid.JumpHeight = 0
char:SetAttribute("Carried", false)
char:SetAttribute("Carry", false)
char:SetAttribute("Throwing", false)
char:SetAttribute("Thrown", false)
char:SetAttribute("ChargingJump", false)
char:SetAttribute("Jumping", false)
char:SetAttribute("JumpLanded", false)
char:SetAttribute("ChargingValue", 0)
task.spawn(function()
local OwnerOfPrompt = game.Players:GetPlayerFromCharacter(Prompt.Parent)
if Prompt then
remote:FireClient(plr, plr, Prompt, OwnerOfPrompt, "promptCleanup")
end
end)
timeOnJoined[tostring(plr.UserId)] = os.time() -- Storing time they joined in table
task.spawn(function()
for _, animation in pairs(game.ReplicatedStorage.Animations:GetChildren()) do
char.Humanoid.Animator:LoadAnimation(animation)
end
end)
Prompt.Triggered:Connect(function(PlrWhoTriggered)
local OwnerOfPrompt = game.Players:GetPlayerFromCharacter(Prompt.Parent)
remote:FireClient(OwnerOfPrompt, PlrWhoTriggered, Prompt, OwnerOfPrompt,"PromptTriggered")
end)
local OwnerOfPrompt = game.Players:GetPlayerFromCharacter(Prompt.Parent)
remote:FireClient(plr, plr, Prompt, OwnerOfPrompt, "promptCleanup")
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
print(plr.Name .. " Has been in game for " .. os.time() - timeOnJoined[tostring(plr.UserId)] .. " Seconds ") -- here its getting the String and subtracting it from the time they joined
timeOnJoined[tostring(plr.UserId)] = nil
end)
This is my Client Script
local Event = game.ReplicatedStorage.RemotesFolder.Event
local PairModule = require(game.ReplicatedStorage.Modules.PairModule)
Event.OnClientEvent:Connect(function(plr, prompt, OwnerOfPrompt, action) -- owner of prompt = player, prompt = specific character Prompt
if action == "promptCleanup" then
for _, Obj in pairs(plr.Character:GetChildren()) do
if Obj:IsA("ProximityPrompt") and Obj.Name == "PairRequestPrompt" then
Obj:Destroy()
end
end
print(prompt)
end
if action == "PromptTriggered" then
task.spawn(function()
local PairedCharacter = OwnerOfPrompt.Character or OwnerOfPrompt.CharacterAdded:Wait()
local pairRequestGui = OwnerOfPrompt.PlayerGui.PairRequestGui
pairRequestGui.Enabled = true
pairRequestGui.PlayerRequestFrame.TextLabel.Text = plr.Name.. " wants to pair with you! "
pairRequestGui.AcceptFrame.ImageButton.Activated:Connect(function()
pairRequestGui.Enabled = false
print("Activated")
PairModule.Pairs(OwnerOfPrompt, plr, "Pair")
end)
pairRequestGui.DeclineFrame.ImageButton.Activated:Connect(function()
print("Activated")
pairRequestGui.Enabled = false
end)
end)
end
end)
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
ive tried looking none related to my presented issue