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

How to make a part that on touch the GUI would tween?

Asked by 5 years ago

So I have a question. In StarterGui there is GUI called "Notifications" and inside of that GUI there is Frame called"BadgeAwardNotifcation" also I have Part in Workspace. That part has script inside. Script code is:

local frame = script.Parent.Parent.Notifications.BadgeAwardNotifcation

function onTouched(hit)
    frame:TweenPosition(UDim2.new(1, -200,0.92, -68))
    wait(5)
    frame:TweenPosition(UDim2.new(1, 100,0.92, -68))    
end
script.Parent.Touched:connect(onTouched)

What do I need to do that on touch the GUI worked properly?

0
You're not directing to the FrameGui on line 1 correctly. Since this this a server script you wouldn't be able to get it either since the server can't see PlayerGui. You'll have to set this up on a local script or use RemoteEvents. xPolarium 1388 — 5y

1 answer

Log in to vote
0
Answered by
HaveASip 494 Moderation Voter
5 years ago

If your filtering is enabled you cant access to player's playergui from server normal script. But if you want to do that, you need to use remote events. For first put in ReplicatedStorage a RemoteEvent. Then type this first code into your brick script:

local Event = game:GetService('ReplicatedStorage'):WaitForChild('Your Event Name') -- put here your event name that you put in rep storage
local Ready = true

function OnTouched(hit)
    if ready == true then -- Using debounce to prevent hit spam
        if hit.Parent:FindFirstChild('Humanoid') then -- checking if hit author is player(not brick)
            ready = false
            local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
            Event:FireClient(player) -- Sending to player information that his hit the brick
            wait(5)
            ready = false
        end
    end
end)
script.Parent.Touched:Connect(OnTouched)

Now insert a localscript into starterGui and type in this code

local Frame = script.Parent.Notifications..BadgeAwardNotifcation
local Event = game:GetService('ReplicatedStorage'):WaitForChild('Your Event Name') --put here your event name again

Event.OnClientEvent:Connect(function() --firing when player hit the brick
    frame:TweenPosition(UDim2.new(1, -200,0.92, -68))
    wait(5)
    frame:TweenPosition(UDim2.new(1, 100,0.92, -68)) 
end)
0
actually FE is always on even if you turn it off User#23365 30 — 5y
0
I said IF, you know what means "if"? HaveASip 494 — 5y
Ad

Answer this question