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

Why won't this script work?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

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. M39a9am3R 3210 — 8y
0
ok, does that help at all? hurricanedog 0 — 8y
0
My only guess is that you've misspelt something. It should be working otherwise. MINEBLOX106 55 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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) 
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 hurricanedog 0 — 8y
Ad

Answer this question