I want, when player use proximity prompt the gui changes its text but it’s not working.
local proximity1 = game.Workspace.BloomCharmixPin.Sphere.ProximityPrompt
local proximity2 = game.Workspace.StellaCharmixPin.default.ProximityPrompt
local proximity3 = game.Workspace.FloraCharmixPin.default.ProximityPrompt
local gui = script.Parent
proximity1.TriggerEnded:Connect(function()
gui.Text += 6
proximity1.Parent.Parent:Destroy()
end)
proximity2.TriggerEnded:Connect(function()
gui.Text += 1
proximity2.Parent.Parent:Destroy()
end)
proximity3.TriggerEnded:Connect(function()
gui.Text += 1
proximity3.Parent.Parent:Destroy()
end)
Tuhgate
(Nightmare)
March 20, 2024, 2:49pm
#2
heres a updated version because you made so many mistakes.
task.wait(1)
local proximity1 = game.Workspace.BloomCharmixPin.Sphere.ProximityPrompt
local proximity2 = game.Workspace.StellaCharmixPin.default.ProximityPrompt
local proximity3 = game.Workspace.FloraCharmixPin.default.ProximityPrompt
local gui = script.Parent
proximity1.TriggerEnded:Connect(function()
gui.Text = tostring(tonumber(gui.Text + 6))
proximity1.Parent.Parent:Destroy()
end)
proximity2.TriggerEnded:Connect(function()
gui.Text = tostring(tonumber(gui.Text + 1)
proximity2.Parent.Parent:Destroy()
end)
proximity3.TriggerEnded:Connect(function()
gui.Text = tostring(tonumber(gui.Text + 1))
proximity3.Parent.Parent:Destroy()
end)
1 Like
Text is a string. You cannot perform arithmetic on a string. Use tonumber ()
1 Like
All your parenthesis are in the wrong place btw
1 Like
Tuhgate
(Nightmare)
March 20, 2024, 2:52pm
#5
i did not became for this one serious ill try to be serious rn.so it should be:
gui.Text = tonumber(gui.Text) + 6
?
1 Like
It is not working in my script. My script worked when I only put one proximityprompt. Would it be better to separate it to 3 scripts?
Tuhgate
(Nightmare)
March 20, 2024, 3:01pm
#7
yes its better, when the script gets error all of them will stop working
or maybe it’s by event. Is there another event I could use for it?
There is the problem because if I collect one then next is not working.
Tuhgate
(Nightmare)
March 20, 2024, 3:35pm
#10
change the scripts.i think your old one is still working.
like your second prompt does the proximityprompt1 event.
it has to be problem with variables.
I changes names of them and still nothing. Is taht a reason if prompt has 3 sec.
Tuhgate
(Nightmare)
March 20, 2024, 3:48pm
#13
did you cloned this script to every prompt?
proximity prompt1:
local proximity1 = game.Workspace.BloomCharmixPin.Sphere.ProximityPrompt
local gui = script.Parent
proximity1.TriggerEnded:Connect(function()
gui.Text = tonumber(gui.Text) + 6
proximity1.Parent.Parent:Destroy()
end)
proximity prompt 2:
local proximity2 = game.Workspace.StellaCgarmixPin.default.ProximityPrompt
local gui = script.Parent
proximity2.TriggerEnded:Connect(function()
gui.Text = tonumber(gui.Text) + 1
proximity1.Parent.Parent:Destroy()
end)
proximity prompt 3:
local proximity3 = game.Workspace.FloraCharmixPin.default.ProximityPrompt
local gui = script.Parent
proximity3.TriggerEnded:Connect(function()
gui.Text = tonumber(gui.Text) + 6
proximity1.Parent.Parent:Destroy()
end)
chance each prompts script to i gave you.
Is the script a LocalScript or a server Script?
If it’s a LocalScript, then the issue might be that the other prompts aren’t loading in time, which would explain why the first prompt is working ok but not the rest
Yes They are in Local. Should I use :WaitForChild
?
1 Like
Yes, it’s recommended to use WaitForChild in LocalScripts since not all Instances will load in time before they are needed
Tuhgate
(Nightmare)
March 20, 2024, 3:55pm
#17
you didnt told me that the script is local
i replied wrong person i was gonna reply @TheCookieDragonPlays sorry about that
2 Likes
sorry, I forgot to tell you about that.
1 Like
Try replacing TriggerEnded
with Triggered
, since TriggerEnded is intended to be used with prompts that need to be held to activate