Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

1 comment

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.

1 answer

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)

2 comments

0

actually FE is always on even if you turn it off

0

I said IF, you know what means "if"?

This discussion is preserved as it was. New answers, comments, and votes are closed.