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

How can i set this Model To cancollide = false and transparency = 1. ?

Asked by
yayachik1 -11
5 years ago
Edited 5 years ago

I'm making a game where when you click on a model it gives you money and plays a sound but only once for each player that clicks on it does anyone know how i could make it so that each player who clicks on my model can no longer see it and can now walk through it but anyone who hasn't clicked on it can still see it and its still a solid object?

thanks.

2 answers

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

Well you can't click on models but you can click on parts.

You need to use a ClickDetector and insert that into your part.

To start you off, you should do this:

part = script.Parent
part.ClickDetector.MouseClick:connect(function()
--insert your code here
end)

And from here on out, don't forget to add your part.Transparency = 1 and your part.CanCollide = false, so therefore your character can walk through the door once it is clicked. I also recommend that you put a wait for after it is clicked, and change the transparency back to 0 and the cancollide back to true, so then it's a normal door.

If you have any further questions feel free to leave me a comment! :)

Ad
Log in to vote
0
Answered by
zblox164 531 Moderation Voter
5 years ago
Edited 5 years ago

If you were wanting to click on a model and do something (which you can't directly) you will need to create a PrimaryPart. You can create a PrimaryPart by inserting a part into the model then click on the model and in the properties menu click beside where it says PrimaryPart. Next click on the object that you want to be the PrimaryPart. The model's PrimaryPart should be the size of the model as a whole (For obvious reasons) . Then put a click detector inside of thePrimaryPart. After that you will need the script. Place a LocalScript inside any client side service (StarterGui, StarterPlayer, or ReplicatedFirst) and use this code as an example. This works for my model which is located in workspace. Code:

local Model = workspace.Model

Model.PrimaryPart.ClickDetector.MouseClick:Connect(function()
    local Cash = game.Players.LocalPlayer.leaderstats.Cash

    -- Gets every part in the model
    local ModelsChildren = Model:GetChildren() 

    for index, value in pairs(ModelsChildren) do -- Loops through the table
        -- Sets the properties
        value.Transparency = 0
        value.CanCollide = false
    end
end)

The reason we use a LocalScript is because it is client side only. This means you can change things for one player but not effect any other players.

Hope this helps!

0
Interesing Nep_Ryker 131 — 5y

Answer this question