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

The Transparency value won't change?

Asked by 4 years ago
Edited 4 years ago

The transparency part of this script is what isn't working. Does anyone know what is wrong with the gear script?

local Mouse = game.Players.LocalPlayer:GetMouse()
local tool = script.Parent
local Equipped = false

tool.Equipped:Connect(function()
    Equipped = true
end)

tool.Unequipped:connect(function()
    Equipped = false
end)

Mouse.Button1Down:Connect(function(player)
    if Equipped then
        local Target = Mouse.Target
        Mouse.TargetFilter = game.Players.LocalPlayer.Character
                if Target.Name == "Dirt" then
            Target.Transparency = Target.Transparency - 0.1
                end
        if Target.Transparency = 1 then 
Target:Destroy() 
local RE = game.ReplicatedStorage.RemoteEvent 
RE:FireServer(player)
        end
    end
end)

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

This may or may not work

local Mouse = game.Players.LocalPlayer:GetMouse()
local tool = script.Parent
local Equipped = false

tool.Equipped:Connect(function()
    Equipped = true
end)

tool.Unequipped:connect(function()
    Equipped = false
end)

Mouse.Button1Down:Connect(function(player)
    if Equipped then
        local Target = Mouse.Target
        Mouse.TargetFilter = game.Players.LocalPlayer.Character
                if Target.Name == "Dirt" then
            Target.Transparency -= 0.1
                end
        if Target.Transparency == 1 then 
Target:Destroy() 
local RE = game.ReplicatedStorage.RemoteEvent 
RE:FireServer(player)
        end
    end
end)
0
I tried it, and it didn't work. The error that popped up was "Players.DeuceyTheHonk.Backpack.Shovel.LocalScript:20: Expected 'then' when parsing if statement, got '='" DeuceyTheHonk 2 — 4y
0
i changed my answer. I think you just had to change the 'if Target.Transparency = 1 then' part to have two == LiLFriks 39 — 4y
1
i also tried it, it hacked my account and the fbi are after me btw on another note completely unrelated can i crash at anybodys house for a few years? botw_legend 502 — 4y
0
yeah sure dude raid6n 2196 — 4y
Ad
Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago

The problem is that you for an extra = for if Target.Transparency = 1 then and an end)

Here's the edited code:

local Mouse = game.Players.LocalPlayer:GetMouse()
local tool = script.Parent
local Equipped = false

tool.Equipped:Connect(
    function()
        Equipped = true
    end
)

tool.Unequipped:connect(
    function()
        Equipped = false
    end
)

Mouse.Button1Down:Connect(
    function(player)
        if Equipped then
            local Target = Mouse.Target
            Mouse.TargetFilter = game.Players.LocalPlayer.Character
            if Target.Name == "Dirt" then
                Target.Transparency = Target.Transparency - 0.1
            end
            if Target.Transparency == 1 then
                Target:Destroy()
                local RE = game.ReplicatedStorage.RemoteEvent
                RE:FireServer(player)
            end
        end
    end
)

Answer this question