Ad
Log in to vote
0

Is it possible to change a bool value from a server script parented to a part?

Asked by 1 month ago
Edited 1 month ago

Here is my code for the part:

local orgPos = script.Parent.CFrame
local InRound = game.ReplicatedStorage.InRound
local BlueTake = game.ReplicatedStorage.Bluetake --Here is the bool value I'm trying to change
local debounce = false


function onTouch(hit)
    if not debounce then
        debounce = true
        print(hit.Parent)
        local plr = game.Players:FindFirstChild(hit.Parent.Name)
        local blue = game:GetService("Teams")["Bloo"]

        if plr and plr.Team == blue then
            script.Parent.CFrame = game.Workspace.Dump.CFrame
            plr:FindFirstChild("leaderstats")
            wait(1)
            plr.leaderstats.Flags.Value += 1
            print("true")
        end
        if InRound.Value then
            print("checked")
            BlueTake.Value = true --Here's what I did
        end 
        debounce = false
    end
end

script.Parent.Touched:Connect(onTouch)  

InRound.Changed:Connect(function()
    if not InRound.Value then
        script.Parent.CFrame = orgPos
    end
end)

Edit: Sorry if I wasn't clear, I'm posting this question because the script didn't change the value and I don't know why.

1 answer

Log in to vote
0
Answered by 1 month ago
Edited 1 month ago

Of course. a script can adjust everything everywhere. except things in the local client :)

part.Touched:Connect(function(x1)
if x1.Parent.Humanoid then BlueTake.Value = true end
end)

Thats all.

Oh also, almost forgot, you can use _G to make strings visible across all the scripts. script1

_G.x1 = 'string'

script2:

print(_G.x1)

Output:

'string'

0
But it didn't work, it didn't adjust anything. Ascarson4 99 — 1mo
0
It is supposed to. you messed up something. show me the whole script TheEagle722 114 — 1mo
0
That is the whole script, there's a boolvalue named Bluetake in Replicatedstorage and I'm trying to get the script to change that value to true if someone touches the part and the round isn't over. Ascarson4 99 — 1mo
0
I can make you a script to change the boolean but you have to make the round thing ok? TheEagle722 114 — 1mo
View all comments (7 more)
0
Thanks, and yes the round thing has already been made and it is working fine, but the boolean isn't changing. Ascarson4 99 — 1mo
0
Let me write a script. TheEagle722 114 — 1mo
0
You also should manage the round with a boolean either. if the round ends the boolean change to false or true idk and all the scripts can see if it ended. it would be easier to do so. TheEagle722 114 — 1mo
0
Yes that's how I manage the round, with the InRound boolean Ascarson4 99 — 1mo
0
then add a line: if InRound.Value == false then and add an end before the end) at the end. i hate you so much english. TheEagle722 114 — 1mo
0
wow, WOW, it worked, why did I not think of this before. Thank you so much. Ascarson4 99 — 1mo
0
You're welcome. TheEagle722 114 — 1mo
Ad

Answer this question