I am having trouble with CanCollide - is there a bug?
I test this local and it all works fine. I test this after publish and only the transparency and color change - but player can walk through the wall.
The ForceField starts out with CanCollide = true Then it gets set to false with a script and players can walk through. I am trying to set it back to CanCollide as part of the below three lines.
All clients see the color change and the transparency change but they can all walk through still.
any help??
workspace.MyForceField.Transparency=.5 workspace.MyForceField.CanCollide=true workspace.MyForceField.Color=Color3.new(150,50,150)
According to your problem, you're saying that another script keeps setting the attribute CanCollide = false
for MyForceField
. (I don't know if I'm getting this wrong; let me know if I am.)
If so, then we must edit the other script that seems to do this and your problem should be solved. (Once you post the other script, I'll edit my answer accordingly.)
With that said, let's make some changes to the following script:
workspace.MyForceField.Transparency=.5 workspace.MyForceField.CanCollide=true workspace.MyForceField.Color=Color3.new(150,50,150)
You have everything correct except for line 3 (I'll edit that). In the meantime, we need to figure a way to keep the CanCollide
attribute remain at true
. To be honest, I think this won't be effective because if we do what I'm about to do, it'll be like a battle between the two scripts. You'd be better off editing the other script. But I'll continue:
workspace.MyForceField.Transparency=.5 workspace.MyForceField.Color=Color3.fromRGB(150,50,150) --or you can change the above line to "workspace.MyForceField.Color=Color3.new(150/255, 50/255, 150/255)... either way works. while true do --what this does is it repeatedly sets the CanCollide attribute of the object to true. wait() workspace.MyForceField.CanCollide=true end
This may or may not work but this is the most we can do to solve this problem given the information (unless you manage to post the other script, I'll make sure to edit my answer to completely fix this problem).
Sorry @rayan1565 - here are more details. The MyForceField is set to CanCollide to true so players can't enter a certain area at the start of the game. Then when they touch a block it runs a script that includes setting CanCollide to false so they can begin the game.
The 3 lines I posted above get run on game reset when the current game has ended and new players teleport in from the waiting area. The problem is when they teleport in they can walk right through the block/wall. I only threw the color and transparency in to see if those lines were actually running and working for all clients. And they do.
Are you saying it seems like the OnTouched script is running somehow again and resetting it back to false? That would make sense - is there a way to put a sort of watch on a block so I can track all changes made to it as the game runs? some sort of debugger thing? rather than prints? I didn't post the entire scripts because they are quite large.
The other odd point is that this works fine when I run local but not when I publish and test on the platform. (The color still changes as does the transparency.) So I thought maybe a client/server thing but I can't figure it out.
In the OnTouched script:
game.Workspace.ForceField2.CanCollide = false