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

Is FE works on local models? can I change property of my player model in workspace by GUI button?

Asked by 4 years ago

So i was making lightsaber that activates with GUI button using Transparency on morphed parts, but the problem that it is local script and i know that FE has to be activated with remote events, but is it works on local player model in workspace? Do i have to make main script and remote events for lightsaber activation?

Here's the script so you can see how it works.

local player = game.Players.LocalPlayer
local plr = player.Character.Name
local toggled = false
local button = script.Parent

local function onButtonActivated()
        game.Workspace:FindFirstChild(plr).LightSaberModel1.Blade.Transparency = 0.3
        game.Workspace:FindFirstChild(plr).LightSaberModel2.Blade.Transparency = 1
end

button.Activated:Connect(onButtonActivated)

there is no any errors in script, and it works perfectly and fine so idk if FE breaks it.

1 answer

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

Firstly, put your ClientScript (LocalScript) on your tool. secondly put a new RemoteEvent and a new ServerScript (Script) in this tool. Now I start from the principle of you use a ScreenGui with on that a TextButton and a Tool.

We go to found the player on the ClientScript (LocalScript) like that

local Player = game:GetService('Players') -- This is the instance in the Players folder on the explorer

it's just a link. You can view this instance when you play on studio and you open the "Players" service on the explorer like that

Now you have see on this instance we've Backpack and PlayerGui. In the PlayerGui you can found your ScreenGui like that

local Player = game:GetService('Players') 
local PlayerGui = Player:WaitForChild('PlayerGui')
local YOUR_SCREENGUI = PlayerGui:WaitForChild('YOUR_SCREENGUI_NAME_HERE')

What's WaitForChild? Click here to see the Dev page

Now we've access to your UI! Congrats! Now your script look like this!

local Tool = script.Parent
local Remote = Tool.RemoteEvent

local Player = game:GetService('Players') 
local PlayerGui = Player:WaitForChild('PlayerGui')
local YOUR_SCREENGUI = PlayerGui:WaitForChild('YOUR_SCREENGUI_NAME_HERE')

YOUR_SCREENGUI.TextButton.Activated:Connect(function() -- Directly execute this function!
    Remote:FireServer()
end)

Now go to your ServerScript (Script) and write thats!

local Tool = script.Parent
local Remote = Tool.RemoteEvent

local Activ = false

Remote.OnServerEvent:Connect(function()
    if not Activ then
        Activ = true
        Tool.Blade.Transparency = 0.3
        Tool.Blade.Transparency = 1
    end
end)

Here's how to make an FE tool. If you have any questions ask them below!

0
i already made it FE, and its not tool, it is mesh that welds to Hands, i was wondering will local script that player model (workspace."LocalPlayer", in my situation it is workspace.DiGamesChannel), so the script was changing the property of blade of the morph with local script. digameschannel 44 — 4y
0
Just modify this to fit with your work with your blade, Doesn't found the player character with the workspace it's a bad metod, use the service Players, he is there for that. I find it unfortunate that my reputation has declined following my response here. Yet I open you to the right voice for better syntax. NiniBlackJackQc 1562 — 4y
0
Just a exemple, here I've weld a part on my LeftHand and I've change the Transparency with a LocalScript (ClientScript) and the server doesn't view the changement. https://gyazo.com/eff10eb15d345d39f4e69b55e6eb1963 NiniBlackJackQc 1562 — 4y
0
Sorry if I don't perfectly understand your question, i,m not english i'm a french developper i want just to help you with my experience. NiniBlackJackQc 1562 — 4y
Ad

Answer this question