Hi everyone! I’ve run into a problem… The script you see down there makes a gui frame tween into position when a part is stepped on! The problem is, that it works once but then the tween just doesnt work anymore. Is there a problem with the tween being stored on a module script?
Btw.: there are no errors!
Thanks for you help!
local Toucher = script.Parent
local debounce = false
local Ui
local Tweens
Toucher.Touched:Connect(function(hit)
if not debounce then
local parent = hit.Parent
if parent then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= "Blacksmith" then
debounce = true
Tweens = require(game.Players[hit.Parent.Name]:WaitForChild("PlayerGui")["Smelt/Craft"].TweenPositions)
Tweens.SelectionIn()
wait(1)
debounce = false
end
end
end
end
end)
Something that may work is to reset the position of the Smelt/Craft when it’s finished tweening. If you tween it, and then try to tween it again without reseting the position of the Frame, it will just become visible where it left off after the last tween. So you may want to use a TouchEnded function to reset the position of your Frame so that it can tween again. Hopefully that works and makes sense.
Did you try putting print statements in each section to see where it stops working?
As @fiveironfan2006 stated, try printing the Position of the GUI frame at the beginning and end of each function call.
You might want to switch that into LocalScript if you’re not doing that already, as it doesn’t seem like it. GUIs should be always handled on the client. You will spare yourself a lot of trouble. Server isn’t able to access player’s GUIs.
I agree with @Sougood. I would try that. Another option (maybe more complex and time consuming, but should work) is to use a RemoteEvent. Then you can use FireServer when a player closes the Frame out, and after that call the SelectionOut() function on the module script.
local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local debounce = false
Toucher.Touched:connect(function(hit)
if not debounce and Player.Character ~= nil then
if hit:IsDescendantOf(Player.Character)
debounce = true
--fill tweening here
debounce = false
end
end
end)
Make sure to use this in LocalScript as GUI coding should be handled on Client side.
Ok guys its a deal lol i know why it didnt work lol i had to communicate with the client as well so the position on the server was right but not on the client… i switched to a local script and now it works perfectly! Thank you guys for you help!