Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Shop ring only opens the ui once, and doesn't work after that?

Asked by
Omzure 94
4 years ago

So, the shop ring is supposed to open a shop UI whenever a player touches the ring, and you could close the shop UI by using a button inside of the shop UI, but for me, the whole process only works once, and it never works again. Plus, there is no error in the output, so I have no idea what is wrong

Normal script inside of the shop ring:


game.Players.PlayerAdded:Connect(function(player) script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then player.PlayerGui.ScreenGui.Frame:TweenPosition(UDim2.new(0.338, 0,0.181, 0),"Out","Quint",.5,true) end end) end)

Local script inside the shop UI close button:


local frame = script.Parent.Parent.Parent script.Parent.MouseButton1Click:Connect(function() frame:TweenPosition(UDim2.new(0.338, 0,1.15, 0),"Out","Quint",.5,true) end)

1 answer

Log in to vote
0
Answered by 4 years ago

(Not tested this but) I think the problem is in how you are implementing your .Touched event. Here is an alternative to try:

script.Parent.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        --Tween gui
    end
end)

If this doesnt fix it, then I would try adding prints into your code so you can see if code is running as expected or not.

Also one thing to consider, why not detect if the ring is touched on the client aswell? Its not really 'exploitable' and would give you quicker feedback/responsiveness.

Ad

Answer this question