I need a some help

i was creating a tycoon and i wanted to make a atext that will say what player claimed this tycoon and its not working. can someone help to fix that?

The script:

local owner = script.Parent.Parent.Parent.Parent.Parent.Owner

if owner and owner.Value then
	script.Parent.Text = owner.Value.."'s Electronic Store"
else
	warn("Owner value not found or invalid")
end
2 Likes

Just to check - is the script being created once the player has claimed the tycoon, or does it always exist?

2 Likes

when player claim the tycoon then will show the player eletronic store

2 Likes

Your script will only run once. Try this one:

local owner = script.Parent.Parent.Parent.Parent.Parent.Owner

if owner then
	owner.Changed:Connect(function(value)
		if value then
			script.Parent.Text = owner.Value.."'s Electronic Store"
		end
	end)
end
2 Likes

its not still working i tried a localscript and a script

2 Likes

Just checking, are you correctly referencing the owner? Personally, I have never seen that many .Parents before in my life so you may be wrongly referencing it.

2 Likes

What is the owner value? A string value? An object value? If it’s an object value, don’t forget to add owner.Value.Name.

2 Likes

Could it be that you are using a Server-Script for this:

local owner = script.Parent.Parent.Parent.Parent.Parent.Owner

if owner and owner.Value then
	script.Parent.Text = owner.Value.."'s Electronic Store"
else
	warn("Owner value not found or invalid")
end

and you are using a Local-Script for the value to change? If that’s the case, then the value will still be “player” for the server and that’s the reason why it won’t change. The change is then not visible for the server. Only for the client.

If I am right, try to use a Server-Script where the value gets changed. Or instead use a Remote-Event.

Put a Remote-Event inside the ReplicatedStorage. Maybe name it something like “ChangeOwnerValueEvent”

Like this:

Server-Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeOwnerValueEvent = ReplicatedStorage:WaitForChild("ChangeOwnerValueEvent")

ChangeOwnerValueEvent.OnServerEvent:Connect(function(Player, Value) -- if you send more than 1 Value then: Example: (Player, Value, House, ...)

    -- in case your game is multiplayer (which it probably is) send a second value to the server which makes sure it is the same tycoon. Or else this change will happen to every tycoon.

	script.Parent.Text = Value.."'s Electronic Store"
end)

Local-Script (just implement this where the value gets changed):

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeOwnerValueEvent = ReplicatedStorage:WaitForChild("ChangeOwnerValueEvent")

ChangeOwnerValueEvent:FireServer() -- put the value inside here, Example: FireServer(owner.Value)
-- if you need to send multiple values: Example: FireServer(owner.Value, "House1", ...)
2 Likes

Firing from client to server should be avoided as much as possible since it’s exploitable.

2 Likes

Isn’t there just an option to secure this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeOwnerValueEvent = ReplicatedStorage:WaitForChild("ChangeOwnerValueEvent")

ChangeOwnerValueEvent.OnServerEvent:Connect(function(Player, Value) -- if you send more than 1 Value then: Example: (Player, Value, House, ...)

    -- in case your game is multiplayer (which it probably is) send a second value to the server which makes sure it is the same tycoon. Or else this change will happen to every tycoon.

	script.Parent.Text = Value.."'s Electronic Store"
end)

by implementing something that checks if the tycoon is taken already? If it is taken then it can just ignore the Event.

1 Like

Client-to-server data transmission is fundamentally vulnerable, as malicious users can manipulate the data being sent. Therefore, its not a good approach to receive important game data from the client. Client should request changes(to the server), not declare them.

You can store game data on the server and send it to the client when the client requests it.

It doesn’t seem inevitable that you need to :FireServer() in this post.

2 Likes

Where exactly are you setting the “Owner” value?
i dont see it anywhere in your script…

it could be that you are not setting the value, or what you’re setting the value to is Nil.

How about you make a script in a part with a .Touched function to detect if a player has touched it. Then, you obtain the Player’s name from that function, and make that value Owner instead?

I don’t know what you’re trying to do here with all these .Parent(s). Like, why would the script’s parent even be the owner?

1 Like