The player and server sees two different things

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I just wanna generate some cactus.
  2. What is the issue? The player and the server sees different things.
  3. What solutions have you tried so far? Changing the amount of time each cactus spawns to check if it was a lag issue.

This is the players view. All the cactus is anchored in the sky.

This is the servers view. All of the cactus is anchored on the ground.

local Cactus1 = game.ReplicatedStorage.Cactus1.Cactus1
local Cactus2 = game.ReplicatedStorage.Cactus2.Cactus2

local CactiNumberOnMap = 0
print(CactiNumberOnMap)
local NumberToGenerate = 500

while wait(0.12) do
	if CactiNumberOnMap <= NumberToGenerate then
		CactiNumberOnMap = CactiNumberOnMap + 1
		
		local RandomX = math.random(-1023.5, 1023.5)
		local RandomZ = math.random(-1023.5, 1023.5)
		local RandomRotation = math.random(-180,180)
		local RandomSize = math.random(1,10)
		RandomSize = RandomSize/10
		
		local OneOrTwo = math.random(1,2)
		
		if OneOrTwo == 1 then
			local Clone = Cactus1.Parent:Clone()
			Clone.Parent = workspace
			Clone.Cactus1.Position = Vector3.new(RandomX, 16.117, RandomZ)
			Clone.Cactus1.Rotation = Vector3.new(0, RandomRotation, 0)
			Clone:ScaleTo(RandomSize)
			Clone.Cactus1.Touched:Connect(function(hit)
				if hit.Name == "Baseplate" then  -- replace this with your baseplate's name
					Clone.Cactus1.Anchored = true
				end
			end)

		elseif OneOrTwo == 2 then
			local Clone = Cactus2.Parent:Clone()
			Clone.Parent = workspace
			Clone.Cactus2.Position = Vector3.new(RandomX, 16.117, RandomZ)
			Clone.Cactus2.Rotation = Vector3.new(0, RandomRotation, 0)
			Clone:ScaleTo(RandomSize)
			Clone.Cactus2.Touched:Connect(function(hit)
				if hit.Name == "Baseplate" then  -- replace this with your baseplate's name
					Clone.Cactus2.Anchored = true
				end
			end)
				
		end
		
	else
		local Time = workspace.Time:GetAttribute("Time")
		print("Done", Time)
		break
	end
end

I gotta ask. Is this a local script?

What the player sees is the Client, what the Server sees is well… the Server. It seems like you’re experiencing a discrepancy between the server and the client views. This might be due to the way you’re handling the cacti Touched event.

You’re using the Touched event to anchor the cacti when they touch the baseplate. However, Touched events are tied to the Network Ownership, meaning that a client can fire Touched events on a BasePart it owns and send it to the server, even if the server doesn’t see it touch anything. This might be the reason for the discrepancy.

To fix this, you could try using WaitForChild() to ensure that the cacti are fully replicated to the client before they’re anchored.

1 Like

Nope only server script. (Filler)

i think what @Capiso21 was hinting as was the fact that the player has network ownership of some parts. If i remember correctly, the player can have network ownership of any non-anchored parts so that the server doesnt have to handle the physics for the non-anchored parts. i cant say what the problem would be exactly, but i would see if setting network ownership of each part to the server/nil would fix it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.