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

Is there a way for me to edit text from a RemoteFunction on a Local script?

I am trying to create a Notification like system. Where say a player buys an item, a simple text pops up on screen for 3 seconds, then destroys it self.

I have the notification working fine, whenever I buy an item I get the notification to pop up and leave perfectly fine, as well as having multiple at the same time. The main issue however is the text itself.

The way my game handles purchases in the shop, is it has your selected item, and the amount you buy. Whenever you click buy, it invokes the server to subtract cash and add the item. The problem is that the variables used to track the amount bought and the name of the item is in the local script, while my Remote Function scripting is server side.

The Remote Functions scripting clones an existing template, puts it in the visible frame, and then deletes it later. I can edit the text from the server, but not from the client, where I can use those variables.

Is there a way for me to

A. Share the variables between the server and client, so I can get the name and amount of the item bought,

OR

B. Edit the text in the client after it has been made, so that the variables won't be an issue.

Here is the script for the Remote Function and Shop bits.

game.ReplicatedStorage.Remotes:WaitForChild("Notification").OnServerInvoke = function(player, art, shop, box, award)
	local inv = player.Inventory
	local notif = player.PlayerGui.UserInterface.Notifs
	local holder = notif.NotifHolder
	local template = notif.Template
	
	if art == "shop" then
		local text = template:Clone()
		text.Parent = holder
		text.Visible = true
		wait(1)
		text:Destroy()
	end
end

and

				if PlayerMoney.Value >= (selectedItemShop.Cost.Value * BuyAmount) then
					Remotes.ShopFunction:InvokeServer("Purchase", selectedItemShop.Name, BuyAmount)
					BuyBTN.Text = "Success!"
					workspace.Sounds.Buy:Play()
					Remotes.Notification:InvokeServer("shop")
					BuyBTN.Text = "Buy".." - $"..MathModule:GetSuffix((selectedItemShop.Cost.Value * BuyAmount))

1 answer

✓ Accepted answer

Instead of using a RemoteFunction to make the notification appear you could probably control that in the LocalScript.Remove line 5 in the LocalScript and replace with what you put in the script for the notification.

local notif = player.PlayerGui.UserInterface.Notifs
local template = notif.Template


if PlayerMoney.Value >= (selectedItemShop.Cost.Value * BuyAmount) then
    Remotes.ShopFunction:InvokeServer("Purchase", selectedItemShop.Name, BuyAmount)
    BuyBTN.Text = "Success!"
    workspace.Sounds.Buy:Play()

    local text = template:Clone()
    text.Parent = holder
    text.Visible = true
    wait(1)       
    text:Destroy()

    BuyBTN.Text = "Buy".." - $"..MathModule:GetSuffix((selectedItemShop.Cost.Value * BuyAmount))

Let me know if this works

2 comments

0

This worked! And since all of my notifications are going into the same Frame, it doesnt matter if they are made from different scripts!

0

I'm glad I could help you!

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