Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't this script work?

I created a car with a brick. The brick is grouped with the car to make a model. In the brick I have a ClickDetector and the following script.

location = script.Parent.Parent.Parent
regen = script.Parent.Parent
save = regen:clone()



function onClicked(hit)
    if hit.Parent.Humanoid~= nil then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        cash = player:WaitForChild("leaderstats").Cash
        if cash.Value >= 100 then
            cash.Value = cash.Value - 100
            back = save:clone()
            wait(1)
            back.Parent = location
            back:MakeJoints()
        else
            print("Not enough Cash") 
        end
    end
end

script.Parent.Touched:connect(onClicked) --might be issue


I am not sure how to read the output bar, but I may think the issue is with the last part of the script. If you could help, that would be great!

This is the whole output bar, if you would like to see it:

21:54:11.675 - Auto-Saving...

21:54:11.726 - No active sound driver detected

21:54:12.348 - httpGet http://assetgame.roblox.com/Asset/?id=160627755&serverplaceid=0&clientinsert=0 failed. Trying again. Error: HTTP 403 (HTTP/1.1 403 Asset is not trusted for this place). Elapsed time: 0.0820705

21:54:12.368 - Content failed for http://assetgame.roblox.com/Asset/?id=160627755&serverplaceid=0&clientinsert=0 because HTTP 403 (HTTP/1.1 403 Asset is not trusted for this place)

21:54:12.369 - Content failed because HTTP 403 (HTTP/1.1 403 Asset is not trusted for this place) Go! system update failed! Is the creator of this game in possesion of the model? Model ID: 160627755

3 comments

0

Is there a message in red with a few blue messages following it? If so, post those with your question so we can try and help you a little better.

0

ok, does that help at all?

0

My only guess is that you've misspelt something. It should be working otherwise.

1 answer

You are indeed correct. The issue is in line 23. Touched is an event of Part. If someone touches a Part, Touched is triggered. As i understood, your trying to detect rather a player has Clicked the part, right? So change line 23 to this:

script.Parent.MouseClick:connect(onClicked) 

1 comment

0

still does't work, and now this appears: 21:39:12.305 - MouseClick is not a valid member of WedgePart 21:39:12.305 - Script 'Workspace.Model.Wedge.regen', Line 23 21:39:12.305 - Stack End

This discussion is preserved as it was. New answers, comments, and votes are closed.