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

Have a model transparent for one player?

Asked by 4 years ago
Edited 4 years ago

I want to have it when some player clicks buy on a SurfaceGui. When the player clicks it, if they have enough coins to buy it then the Model becomes Transparent and CanCollide becomes false, but only for that one player. This is what I have so far, but I don't know how to do the transparent and the canCollide thing:

script.Parent.MouseButton1Down:Connect(function(plr)
    local coins = plr.leaderstats.Coins
    local price = script.Parent.Parent.Parent.Price
    if coins.Value >= price.Value then
        coins.Value = coins.Value - price.Value
    end
end)

This script is a normal script.

The model is in workspace, in a folder "Levels", in a model "Farm1", and the model I want to have transparent and canCollide false is in that model. The models name is "Doorway".

0
ill answer it now im just ganna be gone for a while be right back GamerJanko 50 — 4y
0
OK, thanks! TomasGoldFinch 7 — 4y
0
Whats the models name and where is it Prestory 1395 — 4y
0
Its in workspace, in a folder "Levels", in a model "Farm1", and the model I want to have transparent is in that model. Its name is "Doorway". TomasGoldFinch 7 — 4y
0
Any changes made with a LocalScript will not replicate to the server, thus changing those values in a LocalScript will grant you the desired effect. FIamezR 15 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Use a local script for this. but local scripts cannot work if they are a descendant of workspace (meaning it's a part of workspace, doesn't matter if it's in a folder of workspace), but instead of using script.Parent, you'll have to locate the path like this: workspace.Blah.Blah.MouseButton1Down, since it's a local script, all effects will not replicate to the server (expect if it's an animation, that will show to everyone), now, loop through the children of the model like the following:

for i,v in pairs(Model:GetChildren()) do

end

Now, check if the child is a Part, Union, MeshPart etc like this

for i,v in pairs(Model:GetChildren()) do
    if v:IsA("BasePart") then

    end
end

Now all we have to do is make it transparent

for i,v in pairs(Model:GetChildren()) do
    if v:IsA("BasePart") then
        v.Transparency = 1
    end
end
Ad

Answer this question