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

Script runs and gives points but textbox doesnt change/show?

I created a function which when an item is clicked it sends it to a remoteevent then it gives points to the player. The points work fine but the gui doesnt work?

local player = game.Players.LocalPlayer
local MarketplaceService = game:GetService("MarketplaceService")
local passID = 9339069
local text = game.StarterGui.RareNotifier
game.ReplicatedStorage.DominusEvent.OnServerEvent:Connect(function(player)
local pass1 = player.leaderstats.Credits.Value + 20000
local pass2 = player.leaderstats.Score.Value + 1000
local new1 = player.leaderstats.Credits.Value + 10000
local new2 = player.leaderstats.Score.Value + 1000
text.Guyxx.Visible = true
text.Guyxx.BackgroundTransparency = 0
text.Guyxx.Text = ""..player.Name.. " Found the rare Dominus Frigidus!"
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passID) then
player.leaderstats.Score.Value = pass2
player.leaderstats.Credits.Value = pass1
else
player.leaderstats.Score.Value = new2
player.leaderstats.Credits.Value = new1

	
end


end)

2 comments

0

Try using MarketPlaceService instead of MarketplaceService

0

I have

1 answer

Use PlayerGui instead, not StarterGui.

local MarketplaceService = game:GetService("MarketplaceService")
local passID = 9339069

game.ReplicatedStorage.DominusEvent.OnServerEvent:Connect(function(player)
	local pass1 = player.leaderstats.Credits.Value + 20000
	local pass2 = player.leaderstats.Score.Value + 1000
	local new1 = player.leaderstats.Credits.Value + 10000
	local new2 = player.leaderstats.Score.Value + 1000

	for i, plr in pairs(game.Players:GetPlayers()) do
		local text = plr.PlayerGui.RareNotifier
		text.Guyxx.Visible = true
		text.Guyxx.BackgroundTransparency = 0
		text.Guyxx.Text = ""..player.Name.. " Found the rare Dominus Frigidus!"
	end

if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passID) then
player.leaderstats.Score.Value = pass2
player.leaderstats.Credits.Value = pass1
else
player.leaderstats.Score.Value = new2
player.leaderstats.Credits.Value = new1


end


end)

Edit: The reason it has to be PlayerGui is that StarterGui will only replicate into PlayerGui when the player joins/resets.

10 comments

0

ServerScriptService.Hats.DominusFridgus:4: attempt to index nil with 'PlayerGui'

0

I would like it to run on the server so everyone is able to see it.

0

I just edited it. I made a dumb mistake.

0

It can’t find player as it’s in serverScriptService

0

Then you can go through each player in a loop and change the text.

0

so I delete local player = game.PLayers.LocalPlayer and add what?

0

Alright, sorry that I sound a bit confusing here. I'll just explain what I did (I edited the whole script so hopefully it would suit your needs, and you could edit it to your liking). I made a loop, so the server could loop all the players in the server and change the GUI text. I already explained in my answer why you had to use PlayerGui and not StarterGui.

0

I deleted LocalPlayer because you didn't need it. You already had the player argument from the RemoteEvent, and it would be confusing because their names are the same.

0

Okay I’ll try it in a minute and let you know, thank you for your help

0

It didn't work :/

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