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

How to fix this script??

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
local settengs = script.Settings
--Identified the folder containing our stats
local yPoints1 = settengs.Stat01.Value
local amount1 = settengs.Stat01Amount.Value
local waittime = settengs.WaitTime.Value
--Identified the stats
local ting = 0
--Debouncer

function OnTouch(Touched)
(script.Parent.Touched:connect(OnTouch)

    if ting == 0 then
    ting = 1
    local Touchy = Touched.Parent:FindFirstChild("Humanoid") 

    if Touchy ~= nil then --If the toucher is a humanoid then proceed

        local Player = game.Players:GetPlayerFromCharacter(Touched.Parent) 
        local stats = Player:findFirstChild("leaderstats") 

        if stats ~= nil then
            local StatToIncrease = stats:findFirstChild(yPoints1) -
            StatToIncrease.Value  = StatToIncrease.Value +amount1 
            wait(waittime) 
                print(":Script executed successfully!") 
        end

    end

    ting = 0 --remove debounce
    end

end

script.Parent.Touched:connect(OnTouch)

That gives you the point if you stand on it but i want it so when you shoot the button (With a projectile) you get the point, Not when you stand on it??

0
(Stand on a button) ATRGuestServices 5 — 9y
0
Describw the problem in more depth please because how you explainwd seems to be just a variable problem. User#5978 25 — 9y
0
Well there is a button and when you stand on it, it gives you points (Thats what this script does) but i need it so when you shoot the button with a gun or laser etc i don't mind (And not stand on it) It gives you the point. This script means when you stand on the button it gives you a point but i want it so when you shoot the button it gives you the point. ATRGuestServices 5 — 9y
0
Just add a touched event to the projectiles script to check if it touched the button User#5978 25 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

(Forgive me if I misunderstood your question. It's worded pretty badly) Add this to the top of the function:

if Touched.Name ~= "Bullet" then return end

Change "Bullet" to the name of whatever you want to trigger the button If you want more than one kind of projectile then make it if Touched.Name ~= "Bullet" or Touched.Name ~= "Bullet2" then return end

From the looks of your script, the bullet would need to be in the player's character.

Ad

Answer this question