(SOLVED) After switching ScreenGui to SurfaceGui tween breaks

After switching from a screengui menu to a surfacegui my button tween stopped working and i’m not sure why

local TweenService = game:GetService("TweenService")
local Button = script.Parent
local TweenButton = script.Parent.Parent.ChargeCredits
local exitTween = TweenService:Create(TweenButton, TweenInfo.new(0.15), {Transparency = 1})
local enterTween = TweenService:Create(TweenButton, TweenInfo.new(0.15), {Transparency = 0})

TweenButton.Transparency = 1

Button.MouseEnter:Connect(function()
	enterTween:Play()
	Button.UIStroke.Color = Color3.fromRGB(68, 68, 68)
	Button.UIStroke.Thickness = 4
end)

Button.MouseLeave:Connect(function()
	exitTween:Play()
	Button.UIStroke.Color = Color3.fromRGB(38, 38, 38)
	Button.UIStroke.Thickness = 3
end)

Button.Activated:Connect(function()
	exitTween:Play()
	Button.UIStroke.Color = Color3.fromRGB(38, 38, 38)
	Button.UIStroke.Thickness = 3
end)

image

image

(No error message)

2 Likes

Its because you cant use local scripts in workspace, UNLESS you do the following:

  • Create a new SERVER SCRIPT in the same area, same name as well.
  • Click it, and check the properties. Find a setting called RunContext
  • Set the RunContext value to Client instead of legacy.
    And boom, now you can use client scripts in workspace perfectly fine!
1 Like

So i do the same thing with clicked?

1 Like

Yep! It should fix your issue.

1 Like

image
Thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.