✓ Accepted answer
Hello, your problem is that you're not detecting when a certain player is stepping over a part and you're accessing the StarterGui instead of the player's PlayerGui.
Here's the correct code. Put this in a script inside of your part.
local Players = game:GetService("Players")
local debounce = false
local function onTouched(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not debounce then
debounce = true
local chr = hit.Parent
local plr = Players:GetPlayerFromCharacter(chr)
if plr then
if plr.PlayerGui:FindFirstChild("Buy1") then
if plr.PlayerGui.Buy1.Enabled == false then
plr.PlayerGui.Buy1.Enabled = true
wait(3)
plr.PlayerGui.Buy1.Enabled = false
end
end
end
end
debounce = false
end
end
script.Parent.Touched:connect(onTouched)
Hope this is what you wanted if it isn't tell me.
2 comments
Man thanks you a lot you helped me a lot thanks you thanks you so muchhh :)
Make sure to accept my answer. : ) Happy to help.