What I am trying to do is if the Players name matches the owners name of the tycoon then the player will be able to use the “computer” im coding in the game, making it so others can’t use it just the player that owns the tycoon.
When I click on the text button it doesnt print meaning it isnt working, no errors and no reason why, this should work right??(Local Script)
for i,v in pairs(Buttons) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function(Player)
if Owner.Value == PlayerName then
print("hi")
end
end)
end
end
for i,v in pairs(Buttons:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function(Player)
if Owner.Value == LocalPlayer.Name then
print("test")
end
end)
end
end
local TycoonName = script.Parent.Parent.Parent.Parent
local Tycoon = Workspace.Tycoon.Tycoons["Franchise 1"]
local Owner = Tycoon.TycoonInfo.Owner
local ScrollingFrame = script.Parent.ScrollingFrame
local Buttons = ScrollingFrame:GetChildren()
local LocalPlayer = Players.LocalPlayer
local PlayerName = LocalPlayer.Name
Going between this and the original post, I can’t see anything that wouldn’t work. Are you sure the script, or the part of it that’s an issue at least, is running at all? If there’s any more to the script than the 2 segments you posted, please add those as well.
I added more onto it because I am trying to do what I actually wanted to do, but this is what I would look like.
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
--// Variables
local ScrollingFrame = script.Parent.MainFrame.ScrollingFrame
local Buttons = ScrollingFrame:GetChildren()
local Name = script.Parent.Parent.Parent.Name
local Tycoon = Workspace.Tycoon.Tycoons["Franchise 1"]
local Owner = Tycoon.TycoonInfo.Owner
local LocalPlayer = Players.LocalPlayer
local PlayerName = LocalPlayer.Name
for i,v in pairs(Buttons) do
if v:IsA("TextButton") then
v.MouseButton1Up:Connect(function(plr)
if Owner.Value == PlayerName then
if Owner.Value == nil then
end
--//[Practice]
if v.Name == "StartPractice" then
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Player_Start_Practice:FireServer(plr)
end
--//[Practice]
end
end)
end
end
There are no errors to, so I don’t know why it wouldn’t work, nothing will make this not work. Also when I remove the line of code that checks the verification of the owner and players name match, the whole code works as intended
Can you post an image of where the script’s located in the explorer?
The issue could be that its position is making it not run, that’s really the only other thing I can think of. (if you can’t post an image, then just descriptions, e.g. inside StarterPlayer, inside the GUI, inside workspace, etc.). If it’s inside workspace it might not run.
I can’t exactly verify this but I noticed something.
Nevermind, misread something. Still, my old point stands. Make sure that TycoonInfo does actually exist. Make sure you’re not checking if PlayerName equals a nil value.
Alright yeah seems good, other than that I’m still not sure what else could be causing the issue. If the script still works without the line of code that checks the two, then the only other thing I can think of is that the Owner.Value has some issue. Is it being set properly?
When the player claims the tycoon, the owner value is a Object Value that changes its value to the players name. When the players leaves it loses the value I have used this tycoon for many of my games and never had issues with it, so yes it is set properly. I really have no idea why this isn’t working, I even checked to make sure the value is actually being sent to the client so i printed the owner value and it said my players user and i even printed the LocalPlayer.Name and that also printed my name, everything checks out, and no error in output. Is there some sort of loop hole or other way to pull the players Name and check the owner value? Other than that I do not know what to do.
An ObjectValue or a StringValue? If you print an ObjectValue it’ll print the name of the instance, but setting an object equal to an instance doesn’t work. If it is an ObjectValue, instead change it to a string value. If not, I don’t know what else to do.
So how my whole tycoon system works is that it gets the players owner value through a object value I made this a long time ago so I forgot the point of using the object value rather than string value but when i try to change the info over to string i get this error in my tycoons main server script.