Issue with physics during play testing

Hey devforum!

I have had an issue for a while where when I try to spawn/clone an unanchored block from a ReplicatedStorage folder into Workspace, it cannot be pushed by your avatar in Studio play testing, but you can push it fine in game.

I posted this issue on Reddit a while back, and got an answer suggesting I use network ownership.

block:SetNetworkOwner(nil) -- Server
block:SetNetworkOwner(plr) -- The player who spawned the block

Neither of the above options worked, and now I’m kind of stumped. If you need a video or my code, ask and I can give it, but it might be a while because I’m about to go to bed. Please let me know if you have a solution!

I’m unsure of the exact issue here, so here’s two possible solutions.

1. The move tool isn’t working.
Due to recent keybind changes, ctrl + 1 no longer enables select, ctrl + 2 not move, ect.
The new keybinds are just 1, 2, 3, 4. But these don’t work in playtesting before they would override tool keybinds.
You need to go into the home tab and manually click the tool you want during playtesting.

2. The move tool is working, but the block snaps back when moved.
This means that the server is overriding the position of the block. You need to go in the home tab , and click the server-client swap button (this button only shows up in runtime), to go to the server side, then you should be able to move the block fine.
image

Basically, deleting or changing something in client view makes that change client side only.

Hi,

I’m not using the move tool, this is an unanchored block that I’m pushing with my avatar. I’m editing the post to clarify

Sorry about that

Ah, okay, the block is likely too heavy then, the player doesn’t have much push force.
Try making the block’s size 2x3x2, or decreasing it’s density in the customphysicalproperties section near the bottom of the properties window.

Are these okay?

Screenshot 2024-10-11 at 9.53.26 PM

Should be, though it depends on the size of the box.

The size is 5 studs in all dimensions. I’m still having this issue in studio, but it pushes much better now in game!

That’s really odd, probably something obscure then.
Is this just an empty place? What’s inside it?

Let me see how this acts in an empty place - I can share code snippets if needed!

Code snippets would be a huge help. My current theory is something to do with the player joining the server earlier then expected in studio. Stuff like .PlayerAdded can sometimes fail in studio if the game takes too long to load.

1 Like

I’ve moved this into an empty place and it’s working now! (It was a little buggy at first in the baseplate, but I think that’s just my old laptop lol)

I’ll look into my other scripts (like the ones with PlayerAdded), this game is fairly old and I probably didn’t optimize it too well.

Until then, I’ll mark this as solution :slight_smile:

Thank you!

Here is the main spawner code, also:

-- spawnerModel.BlockToSpawn.Value is the name of the block

local function onClick()
	script["Click - Soft UI"]:Play()
	local existingBlock = workspace:FindFirstChild(spawnerModel.BlockToSpawn.Value .. ID.Value)
	if not existingBlock then
		local clone = block:Clone()
		clone.Parent = workspace
		clone.Name = clone.Name .. ID.Value
		clone.CFrame = spawnPos.CFrame
		clone.Anchored = false
	else
		existingBlock:Destroy()
		onClick()
	end
end

Add some delays maybe that helps?
I have this issue where the game like starts yielding for no reason and glitches out. I hope this gets fixed as a bug report!

1 Like

I would advise using print statements to try and figure out the following things.

  • Is it detecting a click?
  • Is it spawning a block?
  • Is the block unanchored?
    This is an example:
-- spawnerModel.BlockToSpawn.Value is the name of the block

local function onClick()
    print("click detected")
	script["Click - Soft UI"]:Play()
	local existingBlock = workspace:FindFirstChild(spawnerModel.BlockToSpawn.Value .. ID.Value)
	if not existingBlock then
        print("making new block")
		local clone = block:Clone()
		clone.Parent = workspace
		clone.Name = clone.Name .. ID.Value
		clone.CFrame = spawnPos.CFrame
		clone.Anchored = false
        print(clone.Anchored)
	else
        existingBlock:Destroy()
		onClick()
	end
end

There’s no such thing as too many print statements, just make sure to clean them up after! :sweat_smile:

1 Like

Seems to be fixed. I don’t know what happened before, but I’m assuming it’s a fixed bug

Thank you for your time, and sorry for wasting it!

No problem,
studio is just sometimes stupid and sometimes bugs will occur. At least key communication is placed so all of us are also aware as fellow devs!
:slight_smile:

1 Like