How could i get the player in a server script?

Hi, i wanted to ask how could i get the player WITHOUT using touch, i tried using playerAdded but it just doesnt work hers the script:

local Fold = game.Workspace:WaitForChild("tycoon1")

local SC = game.ReplicatedStorage.SC

script.Parent.Touched:Connect(function(hit)
	if hit.Name == Fold.DropType.Value then
		hit:Destroy()
		SC:FireClient()
	end
end)
1 Like

Can I ask why you don’t want to use the touch? It’d be much easier as you can just use Players:GetPlayerFromCharacter().

3 Likes

well because i cant because the script i am using doesnt check for the players touch but a certain parts touch

2 Likes

oh, i see, ignore my previous post (now deleted). In that case, how is the part assigned to the player? you will need to implement some kind of custom logic but it can be as simple as a linear search depending on your data structure.

3 Likes

can you explain it a bit more simple dimple
jokes aside i really dont understand

1 Like

it seams you are working on tycoon,correct me if i am wrong?

3 Likes

well if it doesnt get the player based off of the character that hit the part (or any of the character’s parts at all) then you must have some kind of system where there’s another part that is associated with the player. I’m just asking for info about that system.

Unless you are relying on the character or any of the character’s parts.

2 Likes

yes correct how do you know good sir

1 Like

you can get player by userId if this is tycoon and he have owner value then he can get player by owner value

game.Players:GetPlayerByUserId(UserId)
2 Likes

I suspected a user ID associated system (or a Player associated system) but I just wanted to make sure before I try to give any solutions

4 Likes

Yeah it will works only when Owner Value is written not nil
I think its dropper’s script

local Fold = game.Workspace:WaitForChild("tycoon1")

local SC = game.ReplicatedStorage.SC

script.Parent.Touched:Connect(function(hit)
	if hit.Name == Fold.DropType.Value then
		hit:Destroy()
		SC:FireClient()
	end
end)

:+1:

3 Likes

its the collecter thing at the end of the conveyor thingy

3 Likes

Does SC “RemoteEvent” update the stats of the collected drop value on a SurfaceGui or ScreenGui?

2 Likes

it just collects the value it doesnt display it on any guis

1 Like

I have some questions below:

  1. What does That Remote Event Do in Client?
  2. Is that Remote important to your game?
  3. Do you have some kind of owner value or attribute in your tycoon?
2 Likes

okay here we go, So bassicly i the script is located in the collecter part that collects the parts that the dropper drops, its in a server script, And the remote event is needed to send to the client so the player can recive the cash, i dont have a owner value but i will prob intergrad it

1 Like

You say Transaction is located in client so you have another remote that transfers cash into player’s leaderstats or smth like that?

1 Like

uh well the remote event is firing to a transaction thing to give the player cash

1 Like

if you’re giving the player the cash via a LocalScript, it won’t replicate back to the server, basically the client will think it has a different amount of money to what the server thinks that player has.

just give the player the money on the server.

1 Like

ohh yeah wait a second your right…

2 Likes