Nothing coming in output with local script

Just touching on this: you can only “concatenate an object” if you use tostring on it. Print calls tostring automatically across all its objects and if you run tostring(obj) .. "str", that’ll be successful. Objects have a tostring metamethod that returns their name.

Sometimes I don’t remember to tostring objects in print statements which is why I prefer to use arguments and let print handle that for me automatically. It’d probably be better to concatenate but I only use printing for surface debugging purposes. :stuck_out_tongue:

print(player, "is not Premium") -- player is not Premium

Added benefit of a space automatically being added.

2 Likes

Full fix specially for you:

while true do
	local player = game.Players.LocalPlayer
	if player.MembershipType == Enum.MembershipType.Premium then
		workspace["Zednov's Tycoon Kit"].GameEssentials.Multiplier.Value = 1.25
		print(workspace["Zednov's Tycoon Kit"].GameEssentials.Multiplier.Value)
	else
		print(player..[[is not premium]])
	end
wait(1) --please dont tell me about avoiding wait
end

Put it into StarterPlayerScripts.

If you want to know what's wrong with it
  1. While in workspace, LocalScripts don’t run. They must be parented to ReplicatedFirst/Player or in any descendant of the player.
  2. Abscence of waiting function causes script to run way too fast and it will error.
1 Like

May I ask why are you using a LocalScript to give the player a cash multiplier? You should rather do it on the server in your cash handling script. That way you won’t have to worry about the parenting part, since I’m assuming you don’t have any problems running server scripts.

Also I’ve never tested it but I don’t think MembershipType can change mid game, so you can simply grab it on PlayerAdded in the server script instead of using a loop:

game.Players.PlayerAdded:Connect(function(plr)
    if plr.MembershipType == Enum.MembershipType.Premium then
        --give the player the coins multiplier
    end
end)
1 Like

Just gonna say before I say anything else: I am not the best scripter. I am just an experienced developer who wants to create a big game in the years to come. I started scripting less than 6 months ago.

There is part of your answer. Also, with a server script, changing the value of the multiplier changes the value for the ENTIRE SERVER. Now if you say, “That’s not always the case” then read what I said UP THERE.

And no, I sometimes do have problems with ALL kinds of scripts.

@pewpie12302die I tried it out but somehow what came in the output is this:
08:22:17 -- 1
This came from this part of the script

print(workspace["Zednov's Tycoon Kit"].GameEssentials.Multiplier.Value)

BUT… The output says 1. So obviously now line 4 is not working.


Second, could I use a pcall() function instead?

What’s the initial multiplier value? I think that even though we set the property from the local client, it retrieves data from the server, who still thinks that Multiplier value is the default.
And you don’t really need a pcall(). As far as I know, it’s used when working with services that rely on network (TeleportService, DataStoreService, etc.)

The initial multiplier value is 1. I want to set it to 1.25

Eeek. I’m trying to get your script working, but I can’t because the player instance is now a userdata :cool:
But in theory, your code should work absolutely fine. I’ve done a little research, and it turns out that if you set an IntValue from the client that client will always see only that value and print() tells the local value.

Player is a userdata value and when you try printing it, you’ll get an error because you can’t cocatenate an object with a string.
You could either:

print(player.Name .. " is not premium")

or

print(tostring(player) .. " is not premium")
1 Like

Ugh, my premium ends today. I’ll probably buy another months worth


And script errors at the if statement that checks player’s membership type.

1 Like

I FOUND THE FIX!

The “Multiplier” value’s class must be NumberValue. IntValue cannot store such digits.

1 Like

My bad, I should’ve phrased it better.
You can’t concatenate an object + a string, which is what you did in the script.

1 Like

YESSSSS THANK YOU SO MUCH lol

30 characters :rage:

1 Like

This is fixed, for the most part, Roblox has added an execution exhaustion future. This will just cancel the script out completely.

Still better than losing data.