Tycoon sell options are not working

Alright get a load of this. Im working on a tycoon with a friend of mind and when I test it on studio when the tycoon stuff reach the part that sells them it works. Though when the other guy tests it it doesnt work. When I go into team test it doesn’t work. When I click test under the test tab it works. When i play it in normal roblox it doesn’t work. There are no errors in the output. What the heck is going on!?!?

Here is the script:

local function addPoints(points)
	local player = tycoon.TycoonOwner.Value

	if player then
		local money = player.leaderstats.Tokens
		money.Value = money.Value + points
	end
end

	
local function sellObject(part)
	if part.Parent.Name == "Water pistol" then
		addPoints(1)
		part.Parent:Destroy()
	elseif part.Parent.name == "cWater pistol" then
		addPoints(3)

		part.Parent:Destroy()
	elseif part.Parent.name == "uWater pistol" then
		addPoints(6)
		part.Parent:Destroy()
		
	
	elseif part.Parent.name == "uuWater pistol" then
		addPoints(10)
		part.Parent:Destroy()
	end

end


local function onTouched(otherPart)
	if otherPart:IsDescendantOf(objectsFolder) then
		sellObject(otherPart)
	end
end

deposit.Touched:Connect(onTouched)

Didnt you post a similar topic yesterday?

Yep. But that was when it didnt work at all. Now its just being super weird.

So got any ideas on what is wrong?

Is this done on the server or client?

The server…


So what do you think the issue is?

I think the problem is that you are assigning tycoon.TycoonOwner incorrectly somehow. Can we see the code that sets the Tycoon Owner value?

The claim button turns the value to the player’s name. So the tycoon knows who to give money.
I doubt that’s the issue, but Idk.

local button = script.Parent
local tycoon = script.Parent.Parent

local function getPlayerFromPart(part)
	local character = part.Parent

	if character then
		local player = game.Players:GetPlayerFromCharacter(character)
		return player
	end
end

local function assignTycoon(player)
	local playerValue = Instance.new("ObjectValue")

	playerValue.Name = "TycoonOwned"
	playerValue.Value = tycoon
	playerValue.Parent = player

	tycoon.TycoonOwner.Value = player
end

local function onTouched(otherPart)
	local player = getPlayerFromPart(otherPart)

	if player then
		local tycoonOwned = player:FindFirstChild("TycoonOwned")

		if not tycoonOwned then
			assignTycoon(player)
			button:Destroy()
		end
	end
end

button.Touched:Connect(onTouched)

Were all the script changes applied?

What do you mean?


1 Like

In order for a script to update for other team create members, you must close the script window and it will apply.

If you have script drafts enabled you must apply it from there.

1 Like

Oh. I didn’t know that. Though would that change the out put if I play the game normally in roblox?

1 Like

In a ‘real’ server the code would run as if you never applied changes to the script.

You can learn more about this in the ‘Collaborative Scripting’ section of here.

Ah ok. I never heard of that! Thanks for letting me know. I’ll test it and see if it works.

1 Like

At least that’s what I remember about the draft system.

It worked thanks so much!\


1 Like