Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my block's CanCollide attribute not work after it is published?

Asked by 6 years ago
Edited 6 years ago

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)
0
dont use color3.new use Color.fromRGB User#23365 30 — 6y
0
the color change works - that is not my question phdmysteries 2 — 6y
0
Do you mind posting the other script that seems to keep setting the object to CanCollide = false? RAYAN1565 691 — 6y
0
You don't have to be so rude and say "that is not my question", because you are clearly setting a Color3 the wrong way Shawnyg 4330 — 6y

2 answers

Log in to vote
0
Answered by
RAYAN1565 691 Moderation Voter
6 years ago
Edited 6 years ago

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).

0
it's actually divided by 255 but ok User#19524 175 — 6y
0
@incapaz fixed. RAYAN1565 691 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

Answer this question