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

Can't figure out odd behavior with button script modifying character mode, any advice?

Asked by 6 years ago

Greetings, quite new to these forums, so don't bite too hard.

I've been writing a script that applies a morph (like in some 3D Role-playing games), and it's worked-- for the most part. What's been bothering me for the last few hours is that it's displaying an odd behavior, especially in my tests with a local server/published game.

The script worked fine for say Player1 and Player2, however I could only see my own morph and not the other players morph. It was as if it was applying the morph locally to what the player sees instead of being server-wide. So to try to figure out what I'm doing wrong, I wrote a small example script

Player = game.Players.LocalPlayer
repeat wait() until Player.Character
Character = Player.Character
Character:WaitForChild("Humanoid")
Button = script.Parent
-------------------------------------------------------------------------------------
function test()
    local h = game.Workspace[Player.Name].Humanoid
    h.Parent.Torso.Transparency = 1
end
-------------------------------------------------------------------------------------
Button.MouseButton1Down:connect(test)

This is in the form of a local script that when you click the button, it should make your torso transparent.. I've tried a few things to see if I could get it to work properly, but to no avail. It works only to Player1's perspective, but not Player2's.

I've been stumped on this and I feel it's something really stupid. Any help will be appreciated!

1 answer

Log in to vote
1
Answered by
cailir 284 Moderation Voter
6 years ago
Edited 6 years ago

Hi, iWolfODonnell!

I found an error! If your character is R15 torso does not exist, it is UpperTorso or LowerTorso. here is the fix: This is a localscript

Player = game.Players.LocalPlayer
repeat wait() until Player.Character
Character = Player.Character
Character:WaitForChild("Humanoid")
Button = script.Parent
-------------------------------------------------------------------------------------
function test()
    local h = Character.Humanoid
    if not h.Parent:FindFirstChild('UpperTorso') then    
        h.Parent.Torso.Transparency = 1
    else
        h.Parent.UpperTorso.Transparency = 1
    end
end
-------------------------------------------------------------------------------------
Button.MouseButton1Down:connect(test)

@EDIT > There was an error on the script!

0
That could be an error, however the game this script will be going into will not be using R15. The problem is that it's not showing up for all the players, as in this image. https://imgur.com/a/ANFKe iWolfODonnell 5 — 6y
1
For me it worked fine: http://prntscr.com/iy3jd9 and I've edited the script because of an error! cailir 284 — 6y
0
I think I may have figured out the issue. Experimental Mode was 'Off', so when I turned it back on, everything started to work! I am not sure why they would recommend you turn it off. But thank you nonetheless! iWolfODonnell 5 — 6y
Ad

Answer this question