I’m having issues putting a canvasgroup (frame) onto the screen when the player activates a proximityprompt.
The first time it works all fine, but when the player activates the button in the localscript, it just wont re-appear when I activate the proximityprompt again.
Server script: (proximity prompt handler)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local proximityPrompt = script.Parent
local function onProximityPromptTriggered(player)
local playerGui = player:WaitForChild("PlayerGui")
local frame = playerGui:FindFirstChild("RelicsTeleport"):WaitForChild("Wrapper")
if frame then
local on = TweenService:Create(frame, TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), { GroupTransparency = 0, Position = UDim2.fromScale(0.387, 0.171) })
frame.Visible = true
on:Play()
end
end
proximityPrompt.Triggered:Connect(onProximityPromptTriggered)
Local Script: (in a screengui, under a textbutton)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local proximityPrompt = game.Workspace.Map.Relics["Relic 1"]:WaitForChild("Prox"):WaitForChild("ProximityPrompt")
local proximityPrompt2 = game.Workspace.Map.Relics["Relic 1"]:WaitForChild("CamProx"):WaitForChild("ProximityPrompt")
local union = proximityPrompt.Parent.Parent:WaitForChild("Symbol")
local button = script.Parent.Parent
local imageLabel = script.Parent
local player = game.Players.LocalPlayer
local productId = 2837973045
local normalColor = button.BackgroundColor3
local hoverColor = normalColor:lerp(Color3.new(1, 1, 1), 0.2)
local screenGui = Instance.new("ScreenGui", player.PlayerGui)
screenGui.IgnoreGuiInset = true
local fadeFrame = Instance.new("Frame", screenGui)
fadeFrame.Size = UDim2.new(1, 0, 1, 0)
fadeFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
fadeFrame.BackgroundTransparency = 1
local frame = script.Parent.Parent.Parent.Parent.Parent.Parent
local sound = frame.Click
local off = game:GetService("TweenService"):Create(frame, TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), { GroupTransparency = 1, Position = UDim2.fromScale(0.387, 0.271) } )
button.MouseEnter:Connect(function()
local dataFolder = player:FindFirstChild("Data")
if dataFolder then
local relicsDataFolder = dataFolder:FindFirstChild("RelicsData")
if relicsDataFolder then
local relic1Value = relicsDataFolder:FindFirstChild("Relic1")
if relic1Value and relic1Value.Value == true then
button.BackgroundColor3 = hoverColor
end
end
end
end)
button.MouseLeave:Connect(function()
local dataFolder = player:FindFirstChild("Data")
if dataFolder then
local relicsDataFolder = dataFolder:FindFirstChild("RelicsData")
if relicsDataFolder then
local relic1Value = relicsDataFolder:FindFirstChild("Relic1")
if relic1Value and relic1Value.Value == true then
button.BackgroundColor3 = normalColor
end
end
end
end)
button.MouseButton1Click:Connect(function()
sound:Play()
local dataFolder = player:FindFirstChild("Data")
if dataFolder then
local relicsDataFolder = dataFolder:FindFirstChild("RelicsData")
if relicsDataFolder then
local relic1Value = relicsDataFolder:FindFirstChild("Relic1")
if relic1Value and relic1Value.Value == true then
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)
local fadeInTween = TweenService:Create(fadeFrame, tweenInfo, {BackgroundTransparency = 0})
local fadeOutTween = TweenService:Create(fadeFrame, tweenInfo, {BackgroundTransparency = 1})
fadeInTween.Completed:Connect(function()
player.Character:SetPrimaryPartCFrame(game.Workspace.Map.Relics["Relic 1"]:WaitForChild("Pos").CFrame)
off:Play()
task.wait(0.5)
frame.Visible = false
fadeOutTween:Play()
end)
fadeInTween:Play()
else
local success, result = pcall(function()
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
if success and result then
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)
local tween = TweenService:Create(union, tweenInfo, {Color = Color3.fromRGB(143, 143, 143)})
tween:Play()
union.PointLight.Enabled = true
local sound = union:FindFirstChild("Sound")
if sound then
sound:Play()
end
proximityPrompt.Enabled = false
proximityPrompt2.Enabled = true
end
end
end
end
end)
local function updateIconBasedOnRelic1()
while true do
local dataFolder = player:FindFirstChild("Data")
if dataFolder then
local relicsDataFolder = dataFolder:FindFirstChild("RelicsData")
if relicsDataFolder then
local relic1Value = relicsDataFolder:FindFirstChild("Relic1")
if relic1Value then
if relic1Value.Value == true then
imageLabel.Image = "rbxassetid://118448551311907"
else
imageLabel.Image = "rbxassetid://75694552427029"
end
end
end
end
task.wait(0.1)
end
end
task.spawn(updateIconBasedOnRelic1)
ScreenGui Directory:
Workspace Directory:
Thanks for your help!