Answered by
3 years ago Edited 2 years ago
Answer:
Step-by-step explanation:
First of all, OnMouseButton1Click is not a valid built-in function from ROBLOX. This will return nil.
Secondly, Connect should be :Connect
NOT .Connect
Thirdly, playerfromcharacter is not a function. I believe you meant :GetPlayersFromCharacter.
NOTE: When connecting to a custom function, you need to connect it to that function or else it wouldn't actually fire. (Put Line 1 in the last line of your script, with the improvements I mentioned above).
(Keep in mind, that MouseButton1Click can only fire once the event is called from a GUIObject, so things like Frames, ImageLabels wouldn't work!)
Unlike @youtubemasterwow's answer, it doesn't matter if you use UserinputService for this case since it will still run!
Fixed Script:
02 | local Tool = script.Parent |
03 | local boi = Tool.Parent |
04 | local girl = game.Players:GetPlayerFromCharacter(boi) |
06 | local missile = Instance.new( "Part" ) |
09 | local spawnpos = boi.PrimaryPart.Position |
10 | spawnpos = spawnpos + (b * 10 ) |
11 | missile.Position = spawnpos |
12 | missile.Size = Vector 3. new( 4 , 4 , 4 ) |
13 | missile.Velocity = b * 10 |
14 | missile.BrickColor = BrickColor.new( 1004 ) |
16 | missile.BottomSurface = 0 |
17 | missile.TopSurface = 0 |
18 | missile.Name = "missile" |
19 | missile.Reflectance = 0 |
22 | local force = Instance.new( "BodyForce" ) |
23 | force.force = Vector 3. new( 0 , 98 , 0 ) |
24 | force.Parent = missile |
26 | local creatortag = Instance.new( "ObjectValue" ) |
27 | creatortag.Value = girl |
28 | creatortag.Name = "creator" |
29 | creatortag.Parent = missile |
31 | missile.Parent = game.Workspace |
34 | script.Parent.MouseButton 1 Click:Connect(ball) |
Grammatical errors fixed:
Date: Sun, May 29th, 2022