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

How do I add a model with a clickdetector and a script in it?

Asked by 4 years ago

Ok, Im doing a house that has a forsalesign and when you click on it you own the house. I need help with the forsalesign removal and for it to come back when the player who claimed the house leaves the game. I have tried this so far but it didn't work

local clickDetector2 = script.Parent:WaitForChild("ForSaleSign1ClickDetector")
local Forsalesign = script.Parent
local Player = game.Players.LocalPlayer
    clickDetector2.MouseClick:Connect(function(player)
        if player.name ~= game.Workspace.houses.House2.CurrentOwner.Value then
            game.Workspace.houses.House1.CurrentOwner.Value = player.Name
            script.Parent.Parent["Nobody's House"].Name = game.Workspace.houses.House1.CurrentOwner.Value
            wait(0.1)
            script.Disabled = true
            Forsalesign.Wood.Transparency = 1
            Forsalesign.Wood.CanCollide = false
            Forsalesign.RedPart.Transparency = 1
            Forsalesign.RedPart.Decal.Transparency = 1

            Player.PlayerRemoving:Connect(function(player)
                Forsalesign.Wood.Transparency = 0
                Forsalesign.Wood.CanCollide = true
                Forsalesign.RedPart.Transparency = 0
                Forsalesign.RedPart.Decal.Transparency = 0

            end)

            end
        end)

1 answer

Log in to vote
0
Answered by 4 years ago

From what I understand you can probably move the Forsalesign somewhere outside of the workspace after someone has claimed it . Preferably move it to ServerScriptService because your script is inside of the model and it needs to continue running.

Once the player leaves you can put it back into the workspace for others to see it and claim it again.

0
I tried but It doesn't work atleast in a localserver test Blixtcraft 16 — 4y
Ad

Answer this question