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

Script will not print anything or make any part transparent.What is wrong?

Asked by
bossay6 62
6 years ago
Edited 6 years ago

So basically, I want my local script to randomly decide if a brick is transparent or not from a model. It's not doing that, and it doesn't print anything either, and there are no errors in the output.

Code:

wait()
print("i'm here")
for i, v in pairs(script.Parent.Rocks:GetChildren()) do
    if v.Name == "Part" then
        local fate = math.random(1,2)
        if fate == 1 then
            v.Transparency = 0
            v.CanCollide = true
            print("work")
        elseif fate == 2 then
            v.Transparency = 1
            v.CanCollide = false
            print("work")
        end
    end
end
0
is your script Disabled? piRadians 297 — 6y
0
yes, but it gets enabled by another script (and it activated the script successfully, it's just that this script doesn't work for some reason) bossay6 62 — 6y
0
if it won't even print "i'm here", then I'm almost sure it's because it is disabled. piRadians 297 — 6y
0
well, that's not the case. I even enabled the script in the explorer and it still gives nothing bossay6 62 — 6y
View all comments (8 more)
0
Is it a local or a server script? piRadians 297 — 6y
0
local script, this script is also being activated by another local script bossay6 62 — 6y
0
You should be using BindableEvents instead of relying on the Disabled property. xPolarium 1388 — 6y
0
Don't enable it from a localscript if it is in workspace, don't enable from a script if it is a localscript greatneil80 2647 — 6y
0
OMG ITS BOSSAY, LONG TIME NO SEE DUDE :D greatneil80 2647 — 6y
0
ok ill use bindableevents also hi bossay6 62 — 6y
0
found a easy solution, thanks for the help bossay6 62 — 6y
0
local scripts do not run on workspace if thats the case piRadians 297 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I'm not sure if you've figured this out yet or not, but I'm pretty certain I know the problem. You know filtering enabled? That good old guy that completely destroyed half of Roblox's games when it was forced on all games? Yeah, it makes so local scripts only change things for the local player, so if you were to make a part in a local script, the player that that local script is linked to is the only person that the part appears for.

The issue with your system is that the script isn't being activated like you think it is. For you, it appears to be activated, but your view of the explorer while in a test is a local view, so if something only happens locally, it will still show it in there. The script is only enabling locally, so it's not actually enabling the script, and it's showing that it is in the explorer.

The solution? Put it in a server script, and use another server script to enable the server script. Server scripts change things for all players, and actually affect the place itself, so by using server scripts instead, you can solve your issue.

Now there are some situations where you need certain input information that you can only get from a local script, but you need it to do something in a server script. In a case like this, you would use remote events. If you don't understand what a remote event is, and how it works, watch this video, because that's how I learned it all: https://www.youtube.com/watch?v=4Dc_bri9mjs

0
Sorry if it's long. e.e Knineteen19 307 — 6y
Ad

Answer this question