I would like there to be a pushable wall, only pushable by the client who sees it.
Although I’ve got a local script, cloning the wall from replicated storage, all clients can push and move the wall.
The wall isn’t known to the server. and the script that allows for the pushing is also a local script.
I’m not sure what to do. My understanding is that objects replicated on the client side, only appear to the client that replicated it…
I had a video here… but I’ll have to reupload it… frame rate was to choppy.
I thought I’d done this correctly, but apparently not. any geniuses know whats up?
I actually thought Roblox had gotten rid of the FilteringEnabled option, and made it turned on without the ability to change it. Turns out, the option is still available on Workspace.
I would think the issue here is that FilteringEnabled is not turned on in your game, if you switch it on you should see immediate changes.
Also, I know the video is choppy. My computer picks the worst of times to get laggy.
Now as far as code goes:
– Local script in starter character
function LoadStage()
local propFolder = repStorage:FindFirstChild(“Stage”…stage);
local playerScripts = propFolder.Player:Clone();
playerScripts.Parent = char;
local clientProps = propFolder.ClientProps:Clone();
clientProps.Parent = stageFolder;
end
LoadStage();
and then in the above code, a player folder is placed into the char, which contains a script that controls this:
movePart1.Touch.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if movePart1.Position.X > goal then
movePart1.PrismaticConstraint.Speed = 3.5;
if movePart1.Sound.IsPlaying == false then
movePart1.Sound:Play();
end
if pushAnimation.IsPlaying == false then
pushAnimation:Play();
end
end
end
end)
and thats pretty much it. Its using a prismatic constraint to move it. and the prismatic constraint speed is set to 0 like so:
game:GetService("RunService").RenderStepped:Connect(function(dt)
-- monitor the push animatoin
if pushAnimation.IsPlaying == true and (humanoid.MoveDirection.Magnitude == 0 or (myRoot.Position - movePart1.Touch.Position).magnitude > 3.5)then
pushAnimation:Stop();
movePart1.Sound:Stop();
movePart1.PrismaticConstraint.Speed = 0;
end
end
Okay, so, just tested this with a friend. If your constraint is created on the server and connected to a locally created part, then the locally created part’s physics will replicate.
Right here you are checking if any humanoid touches the block. That will cause all players touching it to move it on all local scripts (all players see it). Since this is in a local script, and you only want the player who is on the particular client to be able to see the movement, then you need to make sure that the Humanoid is the Player’s humanoid.
local hum, chr = hit.Parent:FindFirstChild("Humanoid"), game.Players.LocalPlayer.Character
if hum and chr and hum.Parent == chr then
Edit: Updated code for sanity checks so that it can’t error if the character or humanoid is nil.
movePart1.Touch.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum == game.Players.LocalPlayer.Character.Humanoid then
if movePart1.Position.X > goal then
movePart1.PrismaticConstraint.Speed = 3.5;
if movePart1.Sound.IsPlaying == false then
movePart1.Sound:Play();
end
if pushAnimation.IsPlaying == false then
pushAnimation:Play();
end
end
end
end)
it shouldnt error out, since the hit.Parent should only ever be the client.
so even with the sanity checks its still doing it…
movePart1.Touch.Touched:Connect(function(hit)
local hum, chr = hit.Parent:FindFirstChild("Humanoid"), game.Players.LocalPlayer.Character
if hum and chr and hum.Parent == chr then
if movePart1.Position.X > goal then
movePart1.PrismaticConstraint.Speed = 3.5;
if movePart1.Sound.IsPlaying == false then
movePart1.Sound:Play();
end
if pushAnimation.IsPlaying == false then
pushAnimation:Play();
end
end
end
end)
This is so strange.
The movepart, and the hedges are all client objects. Which means they are unique per say to each client.
they are created with a local script. the code that controls it is also a client script.
Wouldn’t it make sense that something that is created on my machine would not be visible on your machine, for example?
So you shouldn’t be able to control it.
Maybe its cause the control script is in the players character?
Can you show me? I don’t see how the other players would be seeing this movement at this point, unless I’m misunderstanding your intentions.
Edit: If you use gyazo it only takes seconds to post a GIF of the behavior. I think you can also upload the video directly to your post without having to upload it to YouTube first.